Skip to content

Commit

Permalink
Add mkdirCommand to NnfDataMovementProfile
Browse files Browse the repository at this point in the history
Signed-off-by: Dean Roehrich <[email protected]>
  • Loading branch information
roehrich-hpe committed Nov 25, 2024
1 parent 26913a7 commit 7b62ef5
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 28 deletions.
12 changes: 11 additions & 1 deletion api/v1alpha2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
40 changes: 28 additions & 12 deletions api/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
40 changes: 28 additions & 12 deletions api/v1alpha3/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion api/v1alpha4/nnfdatamovementprofile_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/<dm-name>/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
Expand Down
17 changes: 16 additions & 1 deletion config/crd/bases/nnf.cray.hpe.com_nnfdatamovementprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/<dm-name>/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
Expand All @@ -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
Expand All @@ -375,6 +389,7 @@ spec:
- command
- createDestDir
- maxSlots
- mkdirCommand
- slots
- statCommand
type: object
Expand Down

0 comments on commit 7b62ef5

Please sign in to comment.