diff --git a/api/v1alpha4/nnfstorageprofile_types.go b/api/v1alpha4/nnfstorageprofile_types.go index 6adc8b05..6370606e 100644 --- a/api/v1alpha4/nnfstorageprofile_types.go +++ b/api/v1alpha4/nnfstorageprofile_types.go @@ -46,6 +46,16 @@ type NnfStorageProfileLustreCmdLines struct { // Lustre target has been activated PostActivate []string `json:"postActivate,omitempty"` + // PostMount specifies a list of commands to run on the Rabbit (Lustre client) after the Lustre + // target is activated. This includes mounting the Lustre filesystem beforehand and unmounting + // it afterward. + PostMount []string `json:"postMount,omitempty"` + + // PreUnmount specifies a list of commands to run on the Rabbit (Lustre client) before the + // Lustre target is deactivated. This includes mounting the Lustre filesystem beforehand and + // unmounting it afterward. + PreUnmount []string `json:"preUnmount,omitempty"` + // PreDeactivate specifies a list of commands to run on the Rabbit before the // Lustre target is deactivated PreDeactivate []string `json:"preDeactivate,omitempty"` @@ -178,16 +188,16 @@ type NnfStorageProfileCmdLines struct { // MountRabbit specifies mount options for mounting on the Rabbit. MountRabbit string `json:"mountRabbit,omitempty"` - // PreDeactivate specifies a list of commands to run on the Rabbit after the - // file system has been activated - PostActivate []string `json:"postActivate,omitempty"` + // PostMount specifies a list of commands to run on the Rabbit after the + // file system has been activated and mounted. + PostMount []string `json:"postMount,omitempty"` // MountCompute specifies mount options for mounting on the Compute. MountCompute string `json:"mountCompute,omitempty"` - // PreDeactivate specifies a list of commands to run on the Rabbit before the - // file system is deactivated - PreDeactivate []string `json:"preDeactivate,omitempty"` + // PreUnmount specifies a list of commands to run on the Rabbit before the + // file system is deactivated and unmounted. + PreUnmount []string `json:"preUnmount,omitempty"` } // NnfStorageProfileLVMVgChangeCmdLines diff --git a/internal/controller/filesystem_helpers.go b/internal/controller/filesystem_helpers.go index 5b44917f..cb176cb3 100644 --- a/internal/controller/filesystem_helpers.go +++ b/internal/controller/filesystem_helpers.go @@ -348,9 +348,8 @@ func newBindFileSystem(ctx context.Context, c client.Client, nnfNodeStorage *nnf fs.TempDir = fmt.Sprintf("/mnt/temp/%s-%d", nnfNodeStorage.Name, index) fs.CommandArgs.Mount = "-o bind $DEVICE $MOUNT_PATH" - // TODO - fs.CommandArgs.PostMount = cmdLines.PostActivate - fs.CommandArgs.PreUnmount = cmdLines.PreDeactivate + fs.CommandArgs.PostMount = cmdLines.PostMount + fs.CommandArgs.PreUnmount = cmdLines.PreUnmount fs.CommandArgs.Vars = map[string]string{ "$USERID": fmt.Sprintf("%d", nnfNodeStorage.Spec.UserID), "$GROUPID": fmt.Sprintf("%d", nnfNodeStorage.Spec.GroupID), @@ -373,9 +372,8 @@ func newGfs2FileSystem(ctx context.Context, c client.Client, nnfNodeStorage *nnf } else { fs.CommandArgs.Mount = cmdLines.MountCompute } - // TODO - fs.CommandArgs.PostMount = cmdLines.PostActivate - fs.CommandArgs.PreUnmount = cmdLines.PreDeactivate + fs.CommandArgs.PostMount = cmdLines.PostMount + fs.CommandArgs.PreUnmount = cmdLines.PreUnmount fs.CommandArgs.Mkfs = fmt.Sprintf("-O %s", cmdLines.Mkfs) fs.CommandArgs.Vars = map[string]string{ "$CLUSTER_NAME": nnfNodeStorage.Namespace, @@ -402,21 +400,13 @@ func newXfsFileSystem(ctx context.Context, c client.Client, nnfNodeStorage *nnfv } else { fs.CommandArgs.Mount = cmdLines.MountCompute } - // TODO - fs.CommandArgs.PostMount = cmdLines.PostActivate - fs.CommandArgs.PreUnmount = cmdLines.PreDeactivate + fs.CommandArgs.PostMount = cmdLines.PostMount + fs.CommandArgs.PreUnmount = cmdLines.PreUnmount fs.CommandArgs.Mkfs = cmdLines.Mkfs fs.CommandArgs.Vars = map[string]string{ "$USERID": fmt.Sprintf("%d", nnfNodeStorage.Spec.UserID), "$GROUPID": fmt.Sprintf("%d", nnfNodeStorage.Spec.GroupID), } - // TODO - fs.CommandArgs.PostMount = []string{ - "touch $MOUNT_PATH/blake-test", - } - fs.CommandArgs.PreUnmount = []string{ - "ls -al $MOUNT_PATH", - } return &fs, nil } @@ -441,16 +431,10 @@ func newLustreFileSystem(ctx context.Context, c client.Client, nnfNodeStorage *n fs.CommandArgs.MountTarget = cmdLines.MountTarget fs.CommandArgs.Mount = mountCommand fs.CommandArgs.PostActivate = cmdLines.PostActivate + fs.CommandArgs.PostMount = cmdLines.PostMount + fs.CommandArgs.PreUnmount = cmdLines.PreUnmount fs.CommandArgs.PreDeactivate = cmdLines.PreDeactivate fs.TempDir = fmt.Sprintf("/mnt/temp/%s-%d", nnfNodeStorage.Name, index) - // TODO: hook these into CRD - fs.CommandArgs.PostMount = []string{ - "lfs setstripe -E 64K -L mdt -E 16m -c 1 -S 16m -E 1G -c 2 -E 4G -c 4 -E 16G -c 8 -E 64G -c 16 -E -1 -c -1 $MOUNT_PATH", - } - // TODO - fs.CommandArgs.PreUnmount = []string{ - "touch $MOUNT_PATH/preunmount", - } fs.CommandArgs.Vars = map[string]string{ "$USERID": fmt.Sprintf("%d", nnfNodeStorage.Spec.UserID),