From 7b62ef5a3d155032227c44bfb290feee034447b3 Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Mon, 25 Nov 2024 13:39:37 -0600 Subject: [PATCH] Add mkdirCommand to NnfDataMovementProfile Signed-off-by: Dean Roehrich --- api/v1alpha2/conversion.go | 12 +++++- api/v1alpha2/zz_generated.conversion.go | 40 +++++++++++++------ api/v1alpha3/conversion.go | 11 ++++- api/v1alpha3/zz_generated.conversion.go | 40 +++++++++++++------ api/v1alpha4/nnfdatamovementprofile_types.go | 14 ++++++- ....cray.hpe.com_nnfdatamovementprofiles.yaml | 17 +++++++- 6 files changed, 106 insertions(+), 28 deletions(-) diff --git a/api/v1alpha2/conversion.go b/api/v1alpha2/conversion.go index 3825f60b..fcd2475c 100644 --- a/api/v1alpha2/conversion.go +++ b/api/v1alpha2/conversion.go @@ -170,13 +170,19 @@ func (src *NnfDataMovementProfile) ConvertTo(dstRaw conversion.Hub) error { // Manually restore data. restored := &nnfv1alpha4.NnfDataMovementProfile{} - if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { + hasAnno, err := utilconversion.UnmarshalData(src, restored) + if err != nil { return err } + // EDIT THIS FUNCTION! If the annotation is holding anything that is // hub-specific then copy it into 'dst' from 'restored'. // Otherwise, you may comment out UnmarshalData() until it's needed. + if hasAnno { + dst.Data.MkdirCommand = restored.Data.MkdirCommand + } + return nil } @@ -648,3 +654,7 @@ func Convert_v1alpha4_NnfStorageProfileLustreCmdLines_To_v1alpha2_NnfStorageProf func Convert_v1alpha4_NnfSystemStorageSpec_To_v1alpha2_NnfSystemStorageSpec(in *nnfv1alpha4.NnfSystemStorageSpec, out *NnfSystemStorageSpec, s apiconversion.Scope) error { return autoConvert_v1alpha4_NnfSystemStorageSpec_To_v1alpha2_NnfSystemStorageSpec(in, out, s) } + +func Convert_v1alpha4_NnfDataMovementProfileData_To_v1alpha2_NnfDataMovementProfileData(in *nnfv1alpha4.NnfDataMovementProfileData, out *NnfDataMovementProfileData, s apiconversion.Scope) error { + return autoConvert_v1alpha4_NnfDataMovementProfileData_To_v1alpha2_NnfDataMovementProfileData(in, out, s) +} diff --git a/api/v1alpha2/zz_generated.conversion.go b/api/v1alpha2/zz_generated.conversion.go index c90daa08..3ececd93 100644 --- a/api/v1alpha2/zz_generated.conversion.go +++ b/api/v1alpha2/zz_generated.conversion.go @@ -228,11 +228,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1alpha4.NnfDataMovementProfileData)(nil), (*NnfDataMovementProfileData)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha4_NnfDataMovementProfileData_To_v1alpha2_NnfDataMovementProfileData(a.(*v1alpha4.NnfDataMovementProfileData), b.(*NnfDataMovementProfileData), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*NnfDataMovementProfileList)(nil), (*v1alpha4.NnfDataMovementProfileList)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha2_NnfDataMovementProfileList_To_v1alpha4_NnfDataMovementProfileList(a.(*NnfDataMovementProfileList), b.(*v1alpha4.NnfDataMovementProfileList), scope) }); err != nil { @@ -858,6 +853,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1alpha4.NnfDataMovementProfileData)(nil), (*NnfDataMovementProfileData)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_NnfDataMovementProfileData_To_v1alpha2_NnfDataMovementProfileData(a.(*v1alpha4.NnfDataMovementProfileData), b.(*NnfDataMovementProfileData), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1alpha4.NnfStorageProfileCmdLines)(nil), (*NnfStorageProfileCmdLines)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_NnfStorageProfileCmdLines_To_v1alpha2_NnfStorageProfileCmdLines(a.(*v1alpha4.NnfStorageProfileCmdLines), b.(*NnfStorageProfileCmdLines), scope) }); err != nil { @@ -1416,17 +1416,23 @@ func autoConvert_v1alpha4_NnfDataMovementProfileData_To_v1alpha2_NnfDataMovement out.ProgressIntervalSeconds = in.ProgressIntervalSeconds out.CreateDestDir = in.CreateDestDir out.StatCommand = in.StatCommand + // WARNING: in.MkdirCommand requires manual conversion: does not exist in peer-type return nil } -// Convert_v1alpha4_NnfDataMovementProfileData_To_v1alpha2_NnfDataMovementProfileData is an autogenerated conversion function. -func Convert_v1alpha4_NnfDataMovementProfileData_To_v1alpha2_NnfDataMovementProfileData(in *v1alpha4.NnfDataMovementProfileData, out *NnfDataMovementProfileData, s conversion.Scope) error { - return autoConvert_v1alpha4_NnfDataMovementProfileData_To_v1alpha2_NnfDataMovementProfileData(in, out, s) -} - func autoConvert_v1alpha2_NnfDataMovementProfileList_To_v1alpha4_NnfDataMovementProfileList(in *NnfDataMovementProfileList, out *v1alpha4.NnfDataMovementProfileList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1alpha4.NnfDataMovementProfile)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1alpha4.NnfDataMovementProfile, len(*in)) + for i := range *in { + if err := Convert_v1alpha2_NnfDataMovementProfile_To_v1alpha4_NnfDataMovementProfile(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -1437,7 +1443,17 @@ func Convert_v1alpha2_NnfDataMovementProfileList_To_v1alpha4_NnfDataMovementProf func autoConvert_v1alpha4_NnfDataMovementProfileList_To_v1alpha2_NnfDataMovementProfileList(in *v1alpha4.NnfDataMovementProfileList, out *NnfDataMovementProfileList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]NnfDataMovementProfile)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NnfDataMovementProfile, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_NnfDataMovementProfile_To_v1alpha2_NnfDataMovementProfile(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } diff --git a/api/v1alpha3/conversion.go b/api/v1alpha3/conversion.go index 32a98544..14d7d97e 100644 --- a/api/v1alpha3/conversion.go +++ b/api/v1alpha3/conversion.go @@ -170,13 +170,18 @@ func (src *NnfDataMovementProfile) ConvertTo(dstRaw conversion.Hub) error { // Manually restore data. restored := &nnfv1alpha4.NnfDataMovementProfile{} - if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { + hasAnno, err := utilconversion.UnmarshalData(src, restored) + if err != nil { return err } // EDIT THIS FUNCTION! If the annotation is holding anything that is // hub-specific then copy it into 'dst' from 'restored'. // Otherwise, you may comment out UnmarshalData() until it's needed. + if hasAnno { + dst.Data.MkdirCommand = restored.Data.MkdirCommand + } + return nil } @@ -662,3 +667,7 @@ func Convert_v1alpha4_NnfStorageProfileLustreCmdLines_To_v1alpha3_NnfStorageProf func Convert_v1alpha4_NnfSystemStorageSpec_To_v1alpha3_NnfSystemStorageSpec(in *nnfv1alpha4.NnfSystemStorageSpec, out *NnfSystemStorageSpec, s apiconversion.Scope) error { return autoConvert_v1alpha4_NnfSystemStorageSpec_To_v1alpha3_NnfSystemStorageSpec(in, out, s) } + +func Convert_v1alpha4_NnfDataMovementProfileData_To_v1alpha3_NnfDataMovementProfileData(in *nnfv1alpha4.NnfDataMovementProfileData, out *NnfDataMovementProfileData, s apiconversion.Scope) error { + return autoConvert_v1alpha4_NnfDataMovementProfileData_To_v1alpha3_NnfDataMovementProfileData(in, out, s) +} diff --git a/api/v1alpha3/zz_generated.conversion.go b/api/v1alpha3/zz_generated.conversion.go index 3470fa2c..9bfcf61c 100644 --- a/api/v1alpha3/zz_generated.conversion.go +++ b/api/v1alpha3/zz_generated.conversion.go @@ -228,11 +228,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1alpha4.NnfDataMovementProfileData)(nil), (*NnfDataMovementProfileData)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha4_NnfDataMovementProfileData_To_v1alpha3_NnfDataMovementProfileData(a.(*v1alpha4.NnfDataMovementProfileData), b.(*NnfDataMovementProfileData), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*NnfDataMovementProfileList)(nil), (*v1alpha4.NnfDataMovementProfileList)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha3_NnfDataMovementProfileList_To_v1alpha4_NnfDataMovementProfileList(a.(*NnfDataMovementProfileList), b.(*v1alpha4.NnfDataMovementProfileList), scope) }); err != nil { @@ -858,6 +853,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1alpha4.NnfDataMovementProfileData)(nil), (*NnfDataMovementProfileData)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_NnfDataMovementProfileData_To_v1alpha3_NnfDataMovementProfileData(a.(*v1alpha4.NnfDataMovementProfileData), b.(*NnfDataMovementProfileData), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1alpha4.NnfStorageProfileCmdLines)(nil), (*NnfStorageProfileCmdLines)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_NnfStorageProfileCmdLines_To_v1alpha3_NnfStorageProfileCmdLines(a.(*v1alpha4.NnfStorageProfileCmdLines), b.(*NnfStorageProfileCmdLines), scope) }); err != nil { @@ -1416,17 +1416,23 @@ func autoConvert_v1alpha4_NnfDataMovementProfileData_To_v1alpha3_NnfDataMovement out.ProgressIntervalSeconds = in.ProgressIntervalSeconds out.CreateDestDir = in.CreateDestDir out.StatCommand = in.StatCommand + // WARNING: in.MkdirCommand requires manual conversion: does not exist in peer-type return nil } -// Convert_v1alpha4_NnfDataMovementProfileData_To_v1alpha3_NnfDataMovementProfileData is an autogenerated conversion function. -func Convert_v1alpha4_NnfDataMovementProfileData_To_v1alpha3_NnfDataMovementProfileData(in *v1alpha4.NnfDataMovementProfileData, out *NnfDataMovementProfileData, s conversion.Scope) error { - return autoConvert_v1alpha4_NnfDataMovementProfileData_To_v1alpha3_NnfDataMovementProfileData(in, out, s) -} - func autoConvert_v1alpha3_NnfDataMovementProfileList_To_v1alpha4_NnfDataMovementProfileList(in *NnfDataMovementProfileList, out *v1alpha4.NnfDataMovementProfileList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1alpha4.NnfDataMovementProfile)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1alpha4.NnfDataMovementProfile, len(*in)) + for i := range *in { + if err := Convert_v1alpha3_NnfDataMovementProfile_To_v1alpha4_NnfDataMovementProfile(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -1437,7 +1443,17 @@ func Convert_v1alpha3_NnfDataMovementProfileList_To_v1alpha4_NnfDataMovementProf func autoConvert_v1alpha4_NnfDataMovementProfileList_To_v1alpha3_NnfDataMovementProfileList(in *v1alpha4.NnfDataMovementProfileList, out *NnfDataMovementProfileList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]NnfDataMovementProfile)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NnfDataMovementProfile, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_NnfDataMovementProfile_To_v1alpha3_NnfDataMovementProfile(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } diff --git a/api/v1alpha4/nnfdatamovementprofile_types.go b/api/v1alpha4/nnfdatamovementprofile_types.go index 59fb2054..a187c0b6 100644 --- a/api/v1alpha4/nnfdatamovementprofile_types.go +++ b/api/v1alpha4/nnfdatamovementprofile_types.go @@ -84,7 +84,7 @@ type NnfDataMovementProfileData struct { CreateDestDir bool `json:"createDestDir"` // If CreateDestDir is true, then use StatCommand to perform the stat commands. - // Use setpriv to stat the path with the specified UID/GID. + // Use setpriv to execute with the specified UID/GID. // Available $VARS: // HOSTFILE: hostfile that is created and used for mpirun. Contains a list of hosts and the // slots/max_slots for each host. This hostfile is created at @@ -94,6 +94,18 @@ type NnfDataMovementProfileData struct { // PATH: Path to stat // +kubebuilder:default:="mpirun --allow-run-as-root -np 1 --hostfile $HOSTFILE -- setpriv --euid $UID --egid $GID --clear-groups stat --cached never -c '%F' $PATH" StatCommand string `json:"statCommand"` + + // If CreateDestDir is true, then use MkdirCommand to perform the mkdir commands. + // Use setpriv to execute with the specified UID/GID. + // Available $VARS: + // HOSTFILE: hostfile that is created and used for mpirun. Contains a list of hosts and the + // slots/max_slots for each host. This hostfile is created at + // `/tmp//hostfile`. This is the same hostfile used as the one for Command. + // UID: User ID that is inherited from the Workflow + // GID: Group ID that is inherited from the Workflow + // PATH: Path to stat + // +kubebuilder:default:="mpirun --allow-run-as-root -np 1 --hostfile $HOSTFILE -- setpriv --euid $UID --egid $GID --clear-groups mkdir -p $PATH" + MkdirCommand string `json:"mkdirCommand"` } // +kubebuilder:object:root=true diff --git a/config/crd/bases/nnf.cray.hpe.com_nnfdatamovementprofiles.yaml b/config/crd/bases/nnf.cray.hpe.com_nnfdatamovementprofiles.yaml index 7e12c44e..639d2934 100644 --- a/config/crd/bases/nnf.cray.hpe.com_nnfdatamovementprofiles.yaml +++ b/config/crd/bases/nnf.cray.hpe.com_nnfdatamovementprofiles.yaml @@ -330,6 +330,20 @@ spec: use of max_slots in the hostfile. The hostfile is used for both `statCommand` and `Command`. minimum: 0 type: integer + mkdirCommand: + default: mpirun --allow-run-as-root -np 1 --hostfile $HOSTFILE -- + setpriv --euid $UID --egid $GID --clear-groups mkdir -p $PATH + description: |- + If CreateDestDir is true, then use MkdirCommand to perform the mkdir commands. + Use setpriv to execute with the specified UID/GID. + Available $VARS: + HOSTFILE: hostfile that is created and used for mpirun. Contains a list of hosts and the + slots/max_slots for each host. This hostfile is created at + `/tmp//hostfile`. This is the same hostfile used as the one for Command. + UID: User ID that is inherited from the Workflow + GID: Group ID that is inherited from the Workflow + PATH: Path to stat + type: string pinned: default: false description: Pinned is true if this instance is an immutable copy @@ -356,7 +370,7 @@ spec: -c '%F' $PATH description: |- If CreateDestDir is true, then use StatCommand to perform the stat commands. - Use setpriv to stat the path with the specified UID/GID. + Use setpriv to execute with the specified UID/GID. Available $VARS: HOSTFILE: hostfile that is created and used for mpirun. Contains a list of hosts and the slots/max_slots for each host. This hostfile is created at @@ -375,6 +389,7 @@ spec: - command - createDestDir - maxSlots + - mkdirCommand - slots - statCommand type: object