Skip to content

Commit

Permalink
Exit createAllocation if the operation did not run
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Floeder <[email protected]>
  • Loading branch information
ajfloeder committed Feb 15, 2024
1 parent 4296547 commit d41f0a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions internal/controller/nnf_node_storage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ func (r *NnfNodeStorageReconciler) createAllocation(ctx context.Context, nnfNode
}
if ran {
log.Info("Created block device", "allocation", index)
} else if !allocationStatus.Ready {
log.Info("No block device yet", "allocation", index)
return nil, nil
}

// We don't need to activate the block device here. It will be activated either when there is a mkfs, or when it's used
Expand All @@ -247,6 +250,9 @@ func (r *NnfNodeStorageReconciler) createAllocation(ctx context.Context, nnfNode
}
if ran {
log.Info("Created file system", "allocation", index)
} else if !allocationStatus.Ready {
log.Info("No file system yet", "allocation", index)
return nil, nil
}

ran, err = fileSystem.Activate(ctx, allocationStatus.Ready)
Expand All @@ -255,6 +261,9 @@ func (r *NnfNodeStorageReconciler) createAllocation(ctx context.Context, nnfNode
}
if ran {
log.Info("Activated file system", "allocation", index)
} else if !allocationStatus.Ready {
log.Info("No file system activate yet", "allocation", index)
return nil, nil
}

ran, err = fileSystem.SetPermissions(ctx, nnfNodeStorage.Spec.UserID, nnfNodeStorage.Spec.GroupID, allocationStatus.Ready)
Expand All @@ -263,6 +272,9 @@ func (r *NnfNodeStorageReconciler) createAllocation(ctx context.Context, nnfNode
}
if ran {
log.Info("Set file system permission", "allocation", index)
} else if !allocationStatus.Ready {
log.Info("No file system permissions set yet", "allocation", index)
return nil, nil
}

allocationStatus.Ready = true
Expand Down
4 changes: 2 additions & 2 deletions pkg/blockdevice/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (m *MockBlockDevice) Destroy(ctx context.Context) (bool, error) {
}

func (m *MockBlockDevice) Activate(ctx context.Context) (bool, error) {
m.Log.Info("Dctivated mock block device")
m.Log.Info("Activated mock block device")

return true, nil
}
Expand All @@ -65,5 +65,5 @@ func (m *MockBlockDevice) GetDevice() string {
}

func (m *MockBlockDevice) CheckFormatted() (bool, error) {
return false, nil
return true, nil
}
2 changes: 1 addition & 1 deletion pkg/filesystem/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ func (m *MockFileSystem) Unmount(ctx context.Context, path string) (bool, error)
func (m *MockFileSystem) SetPermissions(ctx context.Context, uid uint32, gid uint32, complete bool) (bool, error) {
m.Log.Info("Set mock file system permissions")

return false, nil
return true, nil
}

0 comments on commit d41f0a3

Please sign in to comment.