Skip to content

Commit

Permalink
Add IgnoreOfflineComputes option to NnfAccess
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Richerson <[email protected]>
  • Loading branch information
matthew-richerson committed Nov 25, 2024
1 parent 26913a7 commit 07ad184
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 26 deletions.
15 changes: 14 additions & 1 deletion api/v1alpha2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,20 @@ func (src *NnfAccess) ConvertTo(dstRaw conversion.Hub) error {

// Manually restore data.
restored := &nnfv1alpha4.NnfAccess{}
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.Spec.IgnoreOfflineComputes = restored.Spec.IgnoreOfflineComputes
} else {
dst.Spec.IgnoreOfflineComputes = false
}

return nil
}

Expand Down Expand Up @@ -494,8 +501,10 @@ func (src *NnfSystemStorage) ConvertTo(dstRaw conversion.Hub) error {

if hasAnno {
dst.Spec.Shared = restored.Spec.Shared
dst.Spec.IgnoreOfflineComputes = restored.Spec.IgnoreOfflineComputes
} else {
dst.Spec.Shared = true
dst.Spec.IgnoreOfflineComputes = false
}

return nil
Expand Down Expand Up @@ -648,3 +657,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_NnfAccessSpec_To_v1alpha2_NnfAccessSpec(in *nnfv1alpha4.NnfAccessSpec, out *NnfAccessSpec, s apiconversion.Scope) error {
return autoConvert_v1alpha4_NnfAccessSpec_To_v1alpha2_NnfAccessSpec(in, out, s)
}
41 changes: 29 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.

15 changes: 14 additions & 1 deletion api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,20 @@ func (src *NnfAccess) ConvertTo(dstRaw conversion.Hub) error {

// Manually restore data.
restored := &nnfv1alpha4.NnfAccess{}
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.Spec.IgnoreOfflineComputes = restored.Spec.IgnoreOfflineComputes
} else {
dst.Spec.IgnoreOfflineComputes = false
}

return nil
}

Expand Down Expand Up @@ -501,8 +508,10 @@ func (src *NnfSystemStorage) ConvertTo(dstRaw conversion.Hub) error {

if hasAnno {
dst.Spec.Shared = restored.Spec.Shared
dst.Spec.IgnoreOfflineComputes = restored.Spec.IgnoreOfflineComputes
} else {
dst.Spec.Shared = true
dst.Spec.IgnoreOfflineComputes = false
}

return nil
Expand Down Expand Up @@ -662,3 +671,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_NnfAccessSpec_To_v1alpha3_NnfAccessSpec(in *nnfv1alpha4.NnfAccessSpec, out *NnfAccessSpec, s apiconversion.Scope) error {
return autoConvert_v1alpha4_NnfAccessSpec_To_v1alpha3_NnfAccessSpec(in, out, s)
}
41 changes: 29 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.

3 changes: 3 additions & 0 deletions api/v1alpha4/nnfaccess_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ type NnfAccessSpec struct {

// StorageReference is the NnfStorage reference
StorageReference corev1.ObjectReference `json:"storageReference"`

// +kubebuilder:default=false
IgnoreOfflineComputes bool `json:"ignoreOfflineComputes"`
}

// NnfAccessStatus defines the observed state of NnfAccess
Expand Down
3 changes: 3 additions & 0 deletions api/v1alpha4/nnfsystemstorage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ type NnfSystemStorageSpec struct {
// StorageProfile is an object reference to the storage profile to use
StorageProfile corev1.ObjectReference `json:"storageProfile"`

// +kubebuilder:default:=false
IgnoreOfflineComputes bool `json:"ignoreOfflineComputes"`

// MakeClientMounts specifies whether to make ClientMount resources or just
// make the devices available to the client
// +kubebuilder:default:=false
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/nnf.cray.hpe.com_nnfaccesses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,9 @@ spec:
description: GroupID for the new mount. Currently only used for raw
format: int32
type: integer
ignoreOfflineComputes:
default: false
type: boolean
makeClientMounts:
default: true
description: |-
Expand Down Expand Up @@ -706,6 +709,7 @@ spec:
required:
- desiredState
- groupID
- ignoreOfflineComputes
- makeClientMounts
- storageReference
- target
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/nnf.cray.hpe.com_nnfsystemstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ spec:
items:
type: string
type: array
ignoreOfflineComputes:
default: false
type: boolean
includeComputes:
description: |-
IncludeComputes is a list of computes nodes to use rather than getting the list of compute nodes
Expand Down Expand Up @@ -692,6 +695,7 @@ spec:
type: string
required:
- capacity
- ignoreOfflineComputes
- makeClientMounts
- shared
- storageProfile
Expand Down
28 changes: 28 additions & 0 deletions internal/controller/nnf_access_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,34 @@ func (r *NnfAccessReconciler) getBlockStorageAccessStatus(ctx context.Context, a
for allocationIndex, allocation := range nnfNodeBlockStorage.Spec.Allocations {
for _, nodeName := range allocation.Access {
blockAccess, exists := nnfNodeBlockStorage.Status.Allocations[allocationIndex].Accesses[nodeName]
if access.Spec.IgnoreOfflineComputes {
storage := &dwsv1alpha2.Storage{
ObjectMeta: metav1.ObjectMeta{
Name: nnfNodeBlockStorage.GetNamespace(),
Namespace: "default",
},
}

if err := r.Get(ctx, client.ObjectKeyFromObject(storage), storage); err != nil {
return false, err
}

computeOffline := false
for _, compute := range storage.Status.Access.Computes {
if compute.Name != nodeName {
continue
}

if compute.Status == dwsv1alpha2.OfflineStatus {
computeOffline = true
}
}

// If the compute is offline, don't check its status
if computeOffline {
continue
}
}

// if the map entry doesn't exist in the status section for this node yet, then keep waiting
if !exists {
Expand Down
1 change: 1 addition & 0 deletions internal/controller/nnfsystemstorage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ func (r *NnfSystemStorageReconciler) createNnfAccess(ctx context.Context, nnfSys
} else {
nnfAccess.Spec.Target = "single"
}
nnfAccess.Spec.IgnoreOfflineComputes = nnfSystemStorage.Spec.IgnoreOfflineComputes
nnfAccess.Spec.MakeClientMounts = nnfSystemStorage.Spec.MakeClientMounts
nnfAccess.Spec.MountPath = nnfSystemStorage.Spec.ClientMountPath
nnfAccess.Spec.ClientReference = corev1.ObjectReference{
Expand Down

0 comments on commit 07ad184

Please sign in to comment.