Skip to content

Commit

Permalink
Add profile argument to copy_in/copy_out directives
Browse files Browse the repository at this point in the history
- copy_in/out directives now take a profile=foo argument
- Added profile to NnfDataMovement.Spec
- Uses 'default' profile when not supplied

Signed-off-by: Blake Devcich <[email protected]>
  • Loading branch information
bdevcich committed Nov 16, 2023
1 parent efb9b17 commit 91601a9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
9 changes: 9 additions & 0 deletions api/v1alpha1/nnf_datamovement_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const (
// data movement. Individual nodes may also perform data movement in which case they use the
// NNF Node Name as the namespace.
DataMovementNamespace = "nnf-dm-system"

// The name of the default profile stored in the nnf-dm-config ConfigMap that is used to
// configure Data Movement.
DataMovementProfileDefault = "default"
)

// NnfDataMovementSpec defines the desired state of NnfDataMovement
Expand Down Expand Up @@ -58,6 +62,11 @@ type NnfDataMovementSpec struct {
// +kubebuilder:default:=false
Cancel bool `json:"cancel,omitempty"`

// Profile specifies the name of profile in the nnf-dm-config ConfigMap to be used for
// configuring data movement. Defaults to the default profile.
// +kubebuilder:default:=default
Profile string `json:"profile,omitempty"`

// User defined configuration on how data movement should be performed. This overrides the
// configuration defined in the nnf-dm-config ConfigMap. These values are typically set by the
// Copy Offload API.
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/nnf.cray.hpe.com_nnfdatamovements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ spec:
operation.
format: int32
type: integer
profile:
default: default
description: Profile specifies the name of profile in the nnf-dm-config
ConfigMap to be used for configuring data movement. Defaults to
the default profile.
type: string
source:
description: Source describes the source of the data movement operation
properties:
Expand Down
10 changes: 10 additions & 0 deletions config/dws/nnf-ruleset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ spec:
type: "string"
isRequired: true
isValueRequired: true
- key: "^profile$"
type: "string"
pattern: "^[a-z][a-z0-9-]+$"
isRequired: false
isValueRequired: true
- command: "copy_out"
watchStates: Proposal,DataOut,Teardown
ruleDefs:
Expand All @@ -92,6 +97,11 @@ spec:
type: "string"
isRequired: true
isValueRequired: true
- key: "^profile$"
type: "string"
pattern: "^[a-z][a-z0-9-]+$"
isRequired: false
isValueRequired: true
- command: "container"
watchStates: Proposal,Setup,PreRun,PostRun,Teardown
ruleDefs:
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/nnf_workflow_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,12 @@ func (r *NnfWorkflowReconciler) startDataInOutState(ctx context.Context, workflo
return path
}

// Use a non-default profile for data movement, if supplied
dmProfile, found := dwArgs["profile"]
if !found {
dmProfile = nnfv1alpha1.DataMovementProfileDefault
}

switch fsType {
case "xfs", "gfs2":

Expand Down Expand Up @@ -690,6 +696,7 @@ func (r *NnfWorkflowReconciler) startDataInOutState(ctx context.Context, workflo
},
UserId: workflow.Spec.UserID,
GroupId: workflow.Spec.GroupID,
Profile: dmProfile,
},
}

Expand Down Expand Up @@ -726,6 +733,7 @@ func (r *NnfWorkflowReconciler) startDataInOutState(ctx context.Context, workflo
},
UserId: workflow.Spec.UserID,
GroupId: workflow.Spec.GroupID,
Profile: dmProfile,
},
}

Expand Down
5 changes: 4 additions & 1 deletion internal/controller/nnf_workflow_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,16 @@ var _ = Describe("NNF Workflow Unit Tests", func() {
"Name": Equal(fmt.Sprintf("%s-%d", workflow.Name, 0)),
"Namespace": Equal(workflow.Namespace),
}))

Expect(dm.Spec.Profile).To(Equal(nnfv1alpha1.DataMovementProfileDefault))
})
})

When("using $DW_PERSISTENT_ references", func() {
BeforeEach(func() {
workflow.Spec.DWDirectives = []string{
fmt.Sprintf("#DW persistentdw name=%s", persistentStorageName),
fmt.Sprintf("#DW copy_in source=/lus/maui/my-file.in destination=$DW_PERSISTENT_%s/my-persistent-file.out", strings.ReplaceAll(persistentStorageName, "-", "_")),
fmt.Sprintf("#DW copy_in source=/lus/maui/my-file.in profile=test destination=$DW_PERSISTENT_%s/my-persistent-file.out", strings.ReplaceAll(persistentStorageName, "-", "_")),
}

createPersistentStorageInstance(persistentStorageName, "lustre")
Expand Down Expand Up @@ -581,6 +583,7 @@ var _ = Describe("NNF Workflow Unit Tests", func() {
"Name": Equal(persistentStorageName),
"Namespace": Equal(workflow.Namespace),
}))
Expect(dm.Spec.Profile).To(Equal("test"))
})
})
}) // When("Using copy_in directives", func()
Expand Down

0 comments on commit 91601a9

Please sign in to comment.