Skip to content

Commit

Permalink
Add lustre component count to NnfStorage/NnfNodeStorage API
Browse files Browse the repository at this point in the history
  • Loading branch information
bdevcich committed Dec 3, 2024
1 parent 822b70d commit 189e6a3
Show file tree
Hide file tree
Showing 14 changed files with 488 additions and 148 deletions.
32 changes: 30 additions & 2 deletions api/v1alpha2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"

nnfv1alpha4 "github.com/NearNodeFlash/nnf-sos/api/v1alpha4"
v1alpha4 "github.com/NearNodeFlash/nnf-sos/api/v1alpha4"
utilconversion "github.com/NearNodeFlash/nnf-sos/github/cluster-api/util/conversion"
)

Expand Down Expand Up @@ -343,12 +344,20 @@ func (src *NnfNodeStorage) ConvertTo(dstRaw conversion.Hub) error {

// Manually restore data.
restored := &nnfv1alpha4.NnfNodeStorage{}
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.LustreStorage.LustreComponents.MDTs = append([]string(nil), restored.Spec.LustreStorage.LustreComponents.MDTs...)
dst.Spec.LustreStorage.LustreComponents.MGTs = append([]string(nil), restored.Spec.LustreStorage.LustreComponents.MGTs...)
dst.Spec.LustreStorage.LustreComponents.MGTMDTs = append([]string(nil), restored.Spec.LustreStorage.LustreComponents.MGTMDTs...)
dst.Spec.LustreStorage.LustreComponents.OSTs = append([]string(nil), restored.Spec.LustreStorage.LustreComponents.OSTs...)
dst.Spec.LustreStorage.LustreComponents.NNFNodes = append([]string(nil), restored.Spec.LustreStorage.LustreComponents.NNFNodes...)
}

return nil
}
Expand Down Expand Up @@ -407,12 +416,21 @@ func (src *NnfStorage) ConvertTo(dstRaw conversion.Hub) error {

// Manually restore data.
restored := &nnfv1alpha4.NnfStorage{}
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.Status.LustreComponents.MDTs = append([]string(nil), restored.Status.LustreComponents.MDTs...)
dst.Status.LustreComponents.MGTs = append([]string(nil), restored.Status.LustreComponents.MGTs...)
dst.Status.LustreComponents.MGTMDTs = append([]string(nil), restored.Status.LustreComponents.MGTMDTs...)
dst.Status.LustreComponents.OSTs = append([]string(nil), restored.Status.LustreComponents.OSTs...)
dst.Status.LustreComponents.NNFNodes = append([]string(nil), restored.Status.LustreComponents.NNFNodes...)
}

return nil
}
Expand Down Expand Up @@ -671,3 +689,13 @@ func Convert_v1alpha4_NnfAccessSpec_To_v1alpha2_NnfAccessSpec(in *nnfv1alpha4.Nn
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)
}

// Convert_v1alpha4_LustreStorageSpec_To_v1alpha2_LustreStorageSpec is an autogenerated conversion function.
func Convert_v1alpha4_LustreStorageSpec_To_v1alpha2_LustreStorageSpec(in *v1alpha4.LustreStorageSpec, out *LustreStorageSpec, s apiconversion.Scope) error {
return autoConvert_v1alpha4_LustreStorageSpec_To_v1alpha2_LustreStorageSpec(in, out, s)
}

// Convert_v1alpha4_NnfStorageLustreStatus_To_v1alpha2_NnfStorageLustreStatus is an autogenerated conversion function.
func Convert_v1alpha4_NnfStorageLustreStatus_To_v1alpha2_NnfStorageLustreStatus(in *v1alpha4.NnfStorageLustreStatus, out *NnfStorageLustreStatus, s apiconversion.Scope) error {
return autoConvert_v1alpha4_NnfStorageLustreStatus_To_v1alpha2_NnfStorageLustreStatus(in, out, s)
}
60 changes: 46 additions & 14 deletions api/v1alpha2/zz_generated.conversion.go

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

32 changes: 30 additions & 2 deletions api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"

nnfv1alpha4 "github.com/NearNodeFlash/nnf-sos/api/v1alpha4"
v1alpha4 "github.com/NearNodeFlash/nnf-sos/api/v1alpha4"
utilconversion "github.com/NearNodeFlash/nnf-sos/github/cluster-api/util/conversion"
)

Expand Down Expand Up @@ -342,12 +343,20 @@ func (src *NnfNodeStorage) ConvertTo(dstRaw conversion.Hub) error {

// Manually restore data.
restored := &nnfv1alpha4.NnfNodeStorage{}
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.LustreStorage.LustreComponents.MDTs = append([]string(nil), restored.Spec.LustreStorage.LustreComponents.MDTs...)
dst.Spec.LustreStorage.LustreComponents.MGTs = append([]string(nil), restored.Spec.LustreStorage.LustreComponents.MGTs...)
dst.Spec.LustreStorage.LustreComponents.MGTMDTs = append([]string(nil), restored.Spec.LustreStorage.LustreComponents.MGTMDTs...)
dst.Spec.LustreStorage.LustreComponents.OSTs = append([]string(nil), restored.Spec.LustreStorage.LustreComponents.OSTs...)
dst.Spec.LustreStorage.LustreComponents.NNFNodes = append([]string(nil), restored.Spec.LustreStorage.LustreComponents.NNFNodes...)
}

return nil
}
Expand Down Expand Up @@ -406,12 +415,21 @@ func (src *NnfStorage) ConvertTo(dstRaw conversion.Hub) error {

// Manually restore data.
restored := &nnfv1alpha4.NnfStorage{}
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.Status.LustreComponents.MDTs = append([]string(nil), restored.Status.LustreComponents.MDTs...)
dst.Status.LustreComponents.MGTs = append([]string(nil), restored.Status.LustreComponents.MGTs...)
dst.Status.LustreComponents.MGTMDTs = append([]string(nil), restored.Status.LustreComponents.MGTMDTs...)
dst.Status.LustreComponents.OSTs = append([]string(nil), restored.Status.LustreComponents.OSTs...)
dst.Status.LustreComponents.NNFNodes = append([]string(nil), restored.Status.LustreComponents.NNFNodes...)
}

return nil
}
Expand Down Expand Up @@ -684,3 +702,13 @@ func Convert_v1alpha4_NnfAccessSpec_To_v1alpha3_NnfAccessSpec(in *nnfv1alpha4.Nn
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)
}

// Convert_v1alpha4_LustreStorageSpec_To_v1alpha3_LustreStorageSpec is an autogenerated conversion function.
func Convert_v1alpha4_LustreStorageSpec_To_v1alpha3_LustreStorageSpec(in *v1alpha4.LustreStorageSpec, out *LustreStorageSpec, s apiconversion.Scope) error {
return autoConvert_v1alpha4_LustreStorageSpec_To_v1alpha3_LustreStorageSpec(in, out, s)
}

// Convert_v1alpha4_NnfStorageLustreStatus_To_v1alpha3_NnfStorageLustreStatus is an autogenerated conversion function.
func Convert_v1alpha4_NnfStorageLustreStatus_To_v1alpha3_NnfStorageLustreStatus(in *v1alpha4.NnfStorageLustreStatus, out *NnfStorageLustreStatus, s apiconversion.Scope) error {
return autoConvert_v1alpha4_NnfStorageLustreStatus_To_v1alpha3_NnfStorageLustreStatus(in, out, s)
}
60 changes: 46 additions & 14 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/nnfnodestorage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ type LustreStorageSpec struct {
// BackFs is the type of backing filesystem to use.
// +kubebuilder:validation:Enum=ldiskfs;zfs
BackFs string `json:"backFs,omitempty"`

// Component info for the Lustre filesystem
LustreComponents NnfStorageLustreComponents `json:"lustreComponents,omitempty"`
}

// NnfNodeStorageStatus defines the status for NnfNodeStorage
Expand Down
12 changes: 12 additions & 0 deletions api/v1alpha4/nnfstorage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ type NnfStorageLustreSpec struct {
PersistentMgsReference corev1.ObjectReference `json:"persistentMgsReference,omitempty"`
}

// TODO: document these
type NnfStorageLustreComponents struct {
MDTs []string `json:"mdts,omitempty"`
MGTs []string `json:"mgts,omitempty"`
MGTMDTs []string `json:"mgtmdts,omitempty"`
OSTs []string `json:"osts,omitempty"`
NNFNodes []string `json:"nnfNodes,omitempty"`
}

// NnfStorageAllocationSetSpec defines the details for an allocation set
type NnfStorageAllocationSetSpec struct {
// Name is a human readable label for this set of allocations (e.g., xfs)
Expand Down Expand Up @@ -124,6 +133,9 @@ type NnfStorageLustreStatus struct {
// LustgreMgtReference is an object reference to the NnfLustreMGT resource used
// by the NnfStorage
LustreMgtReference corev1.ObjectReference `json:"lustreMgtReference,omitempty"`

// Component info for the Lustre filesystem
LustreComponents NnfStorageLustreComponents `json:"lustreComponents,omitempty"`
}

// NnfStorageStatus defines the observed status of NNF Storage.
Expand Down
Loading

0 comments on commit 189e6a3

Please sign in to comment.