Skip to content

Commit

Permalink
Add PostMount/PreUnmount Support to lustre; Rename PostActivate/PreDe…
Browse files Browse the repository at this point in the history
…activate for non-lustre

We currently do not have a way to perform actions (e.g. `lfs setstripe`)
on lustre filesystems from the client side. For situations like
`DataIn`, there is no way to prepare the lustre filesystem prior to data
movement.

This change adds PostMount and PreUnmount command lines to the
NnfStorageProfile to allow commands to be run in those situations.

- For lustre filesystems, PostMount and PreUnmount have been added in
  addition to the existing PostActivate/PreDeactivate commands
- PostActivate/PreDeactivate are performed server-side
- PostMount/PreUnmount are performed client-side
- For XFS/GFS2 filesystems, PostActivate/PreDeactivate have been
  renamed to PostMount/PreUnmount

For lustre, multiple NnfNodeStorages are created for each OST, MDT, and
MGT. PostMount should only happen once, so OST0 is what is used. Before
the filesystem can be mounted to run the commands, we need ensure that
all other NnfNodeStorages are ready. Once that happens, OST0 can then be
created and then the NnfNodeStorage controller can run the PostMount
commands. The opposite logic applies in the PreUnmount case where OST0
is now deleted first and performs the PreUnmount commands.

For XFS/GFS2, there is no issue of ordering.

Signed-off-by: Blake Devcich <[email protected]>
  • Loading branch information
bdevcich committed Nov 20, 2024
1 parent 3411791 commit 17ac743
Show file tree
Hide file tree
Showing 21 changed files with 587 additions and 165 deletions.
20 changes: 14 additions & 6 deletions api/v1alpha1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,18 +437,26 @@ func (src *NnfStorageProfile) ConvertTo(dstRaw conversion.Hub) error {
if hasAnno {
dst.Data.LustreStorage.MgtCmdLines.PostActivate = append([]string(nil), restored.Data.LustreStorage.MgtCmdLines.PostActivate...)
dst.Data.LustreStorage.MgtCmdLines.PreDeactivate = append([]string(nil), restored.Data.LustreStorage.MgtCmdLines.PreDeactivate...)
dst.Data.LustreStorage.MgtCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.MgtCmdLines.PostMount...)
dst.Data.LustreStorage.MgtCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.MgtCmdLines.PreUnmount...)
dst.Data.LustreStorage.MgtMdtCmdLines.PostActivate = append([]string(nil), restored.Data.LustreStorage.MgtMdtCmdLines.PostActivate...)
dst.Data.LustreStorage.MgtMdtCmdLines.PreDeactivate = append([]string(nil), restored.Data.LustreStorage.MgtMdtCmdLines.PreDeactivate...)
dst.Data.LustreStorage.MgtMdtCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.MgtMdtCmdLines.PostMount...)
dst.Data.LustreStorage.MgtMdtCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.MgtMdtCmdLines.PreUnmount...)
dst.Data.LustreStorage.MdtCmdLines.PostActivate = append([]string(nil), restored.Data.LustreStorage.MdtCmdLines.PostActivate...)
dst.Data.LustreStorage.MdtCmdLines.PreDeactivate = append([]string(nil), restored.Data.LustreStorage.MdtCmdLines.PreDeactivate...)
dst.Data.LustreStorage.MdtCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.MdtCmdLines.PostMount...)
dst.Data.LustreStorage.MdtCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.MdtCmdLines.PreUnmount...)
dst.Data.LustreStorage.OstCmdLines.PostActivate = append([]string(nil), restored.Data.LustreStorage.OstCmdLines.PostActivate...)
dst.Data.LustreStorage.OstCmdLines.PreDeactivate = append([]string(nil), restored.Data.LustreStorage.OstCmdLines.PreDeactivate...)
dst.Data.RawStorage.CmdLines.PostActivate = append([]string(nil), restored.Data.RawStorage.CmdLines.PostActivate...)
dst.Data.RawStorage.CmdLines.PreDeactivate = append([]string(nil), restored.Data.RawStorage.CmdLines.PreDeactivate...)
dst.Data.XFSStorage.CmdLines.PostActivate = append([]string(nil), restored.Data.XFSStorage.CmdLines.PostActivate...)
dst.Data.XFSStorage.CmdLines.PreDeactivate = append([]string(nil), restored.Data.XFSStorage.CmdLines.PreDeactivate...)
dst.Data.GFS2Storage.CmdLines.PostActivate = append([]string(nil), restored.Data.GFS2Storage.CmdLines.PostActivate...)
dst.Data.GFS2Storage.CmdLines.PreDeactivate = append([]string(nil), restored.Data.GFS2Storage.CmdLines.PreDeactivate...)
dst.Data.LustreStorage.OstCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.OstCmdLines.PostMount...)
dst.Data.LustreStorage.OstCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.OstCmdLines.PreUnmount...)
dst.Data.RawStorage.CmdLines.PostMount = append([]string(nil), restored.Data.RawStorage.CmdLines.PostMount...)
dst.Data.RawStorage.CmdLines.PreUnmount = append([]string(nil), restored.Data.RawStorage.CmdLines.PreUnmount...)
dst.Data.XFSStorage.CmdLines.PostMount = append([]string(nil), restored.Data.XFSStorage.CmdLines.PostMount...)
dst.Data.XFSStorage.CmdLines.PreUnmount = append([]string(nil), restored.Data.XFSStorage.CmdLines.PreUnmount...)
dst.Data.GFS2Storage.CmdLines.PostMount = append([]string(nil), restored.Data.GFS2Storage.CmdLines.PostMount...)
dst.Data.GFS2Storage.CmdLines.PreUnmount = append([]string(nil), restored.Data.GFS2Storage.CmdLines.PreUnmount...)
}

return nil
Expand Down
6 changes: 4 additions & 2 deletions api/v1alpha1/zz_generated.conversion.go

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

20 changes: 14 additions & 6 deletions api/v1alpha2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,18 +437,26 @@ func (src *NnfStorageProfile) ConvertTo(dstRaw conversion.Hub) error {
if hasAnno {
dst.Data.LustreStorage.MgtCmdLines.PostActivate = append([]string(nil), restored.Data.LustreStorage.MgtCmdLines.PostActivate...)
dst.Data.LustreStorage.MgtCmdLines.PreDeactivate = append([]string(nil), restored.Data.LustreStorage.MgtCmdLines.PreDeactivate...)
dst.Data.LustreStorage.MgtCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.MgtCmdLines.PostMount...)
dst.Data.LustreStorage.MgtCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.MgtCmdLines.PreUnmount...)
dst.Data.LustreStorage.MgtMdtCmdLines.PostActivate = append([]string(nil), restored.Data.LustreStorage.MgtMdtCmdLines.PostActivate...)
dst.Data.LustreStorage.MgtMdtCmdLines.PreDeactivate = append([]string(nil), restored.Data.LustreStorage.MgtMdtCmdLines.PreDeactivate...)
dst.Data.LustreStorage.MgtMdtCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.MgtMdtCmdLines.PostMount...)
dst.Data.LustreStorage.MgtMdtCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.MgtMdtCmdLines.PreUnmount...)
dst.Data.LustreStorage.MdtCmdLines.PostActivate = append([]string(nil), restored.Data.LustreStorage.MdtCmdLines.PostActivate...)
dst.Data.LustreStorage.MdtCmdLines.PreDeactivate = append([]string(nil), restored.Data.LustreStorage.MdtCmdLines.PreDeactivate...)
dst.Data.LustreStorage.MdtCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.MdtCmdLines.PostMount...)
dst.Data.LustreStorage.MdtCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.MdtCmdLines.PreUnmount...)
dst.Data.LustreStorage.OstCmdLines.PostActivate = append([]string(nil), restored.Data.LustreStorage.OstCmdLines.PostActivate...)
dst.Data.LustreStorage.OstCmdLines.PreDeactivate = append([]string(nil), restored.Data.LustreStorage.OstCmdLines.PreDeactivate...)
dst.Data.RawStorage.CmdLines.PostActivate = append([]string(nil), restored.Data.RawStorage.CmdLines.PostActivate...)
dst.Data.RawStorage.CmdLines.PreDeactivate = append([]string(nil), restored.Data.RawStorage.CmdLines.PreDeactivate...)
dst.Data.XFSStorage.CmdLines.PostActivate = append([]string(nil), restored.Data.XFSStorage.CmdLines.PostActivate...)
dst.Data.XFSStorage.CmdLines.PreDeactivate = append([]string(nil), restored.Data.XFSStorage.CmdLines.PreDeactivate...)
dst.Data.GFS2Storage.CmdLines.PostActivate = append([]string(nil), restored.Data.GFS2Storage.CmdLines.PostActivate...)
dst.Data.GFS2Storage.CmdLines.PreDeactivate = append([]string(nil), restored.Data.GFS2Storage.CmdLines.PreDeactivate...)
dst.Data.LustreStorage.OstCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.OstCmdLines.PostMount...)
dst.Data.LustreStorage.OstCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.OstCmdLines.PreUnmount...)
dst.Data.RawStorage.CmdLines.PostMount = append([]string(nil), restored.Data.RawStorage.CmdLines.PostMount...)
dst.Data.RawStorage.CmdLines.PreUnmount = append([]string(nil), restored.Data.RawStorage.CmdLines.PreUnmount...)
dst.Data.XFSStorage.CmdLines.PostMount = append([]string(nil), restored.Data.XFSStorage.CmdLines.PostMount...)
dst.Data.XFSStorage.CmdLines.PreUnmount = append([]string(nil), restored.Data.XFSStorage.CmdLines.PreUnmount...)
dst.Data.GFS2Storage.CmdLines.PostMount = append([]string(nil), restored.Data.GFS2Storage.CmdLines.PostMount...)
dst.Data.GFS2Storage.CmdLines.PreUnmount = append([]string(nil), restored.Data.GFS2Storage.CmdLines.PreUnmount...)
}

return nil
Expand Down
6 changes: 4 additions & 2 deletions api/v1alpha2/zz_generated.conversion.go

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

54 changes: 53 additions & 1 deletion api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package v1alpha3

import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
apiconversion "k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/conversion"
logf "sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -425,12 +426,37 @@ func (src *NnfStorageProfile) ConvertTo(dstRaw conversion.Hub) error {

// Manually restore data.
restored := &nnfv1alpha4.NnfStorageProfile{}
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.LustreStorage.MgtCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.MgtCmdLines.PostMount...)
dst.Data.LustreStorage.MgtCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.MgtCmdLines.PreUnmount...)
dst.Data.LustreStorage.MgtMdtCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.MgtMdtCmdLines.PostMount...)
dst.Data.LustreStorage.MgtMdtCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.MgtMdtCmdLines.PreUnmount...)
dst.Data.LustreStorage.MdtCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.MdtCmdLines.PostMount...)
dst.Data.LustreStorage.MdtCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.MdtCmdLines.PreUnmount...)
dst.Data.LustreStorage.OstCmdLines.PostMount = append([]string(nil), restored.Data.LustreStorage.OstCmdLines.PostMount...)
dst.Data.LustreStorage.OstCmdLines.PreUnmount = append([]string(nil), restored.Data.LustreStorage.OstCmdLines.PreUnmount...)
dst.Data.RawStorage.CmdLines.PostMount = append([]string(nil), restored.Data.RawStorage.CmdLines.PostMount...)
dst.Data.RawStorage.CmdLines.PreUnmount = append([]string(nil), restored.Data.RawStorage.CmdLines.PreUnmount...)
dst.Data.XFSStorage.CmdLines.PostMount = append([]string(nil), restored.Data.XFSStorage.CmdLines.PostMount...)
dst.Data.XFSStorage.CmdLines.PreUnmount = append([]string(nil), restored.Data.XFSStorage.CmdLines.PreUnmount...)
dst.Data.GFS2Storage.CmdLines.PostMount = append([]string(nil), restored.Data.GFS2Storage.CmdLines.PostMount...)
dst.Data.GFS2Storage.CmdLines.PreUnmount = append([]string(nil), restored.Data.GFS2Storage.CmdLines.PreUnmount...)
} else {
// For non-lustre, PostActivate is now PostMount and PreDeactivate is now PreUnmount
dst.Data.RawStorage.CmdLines.PostMount = src.Data.RawStorage.CmdLines.PostActivate
dst.Data.XFSStorage.CmdLines.PostMount = src.Data.XFSStorage.CmdLines.PostActivate
dst.Data.GFS2Storage.CmdLines.PostMount = src.Data.GFS2Storage.CmdLines.PostActivate
dst.Data.RawStorage.CmdLines.PreUnmount = src.Data.RawStorage.CmdLines.PreDeactivate
dst.Data.XFSStorage.CmdLines.PreUnmount = src.Data.XFSStorage.CmdLines.PreDeactivate
dst.Data.GFS2Storage.CmdLines.PreUnmount = src.Data.GFS2Storage.CmdLines.PreDeactivate
}

return nil
}
Expand All @@ -443,6 +469,14 @@ func (dst *NnfStorageProfile) ConvertFrom(srcRaw conversion.Hub) error {
return err
}

// For non-lustre, PostActivate is now PostMount and PreDeactivate is now PreUnmount
dst.Data.RawStorage.CmdLines.PostActivate = src.Data.RawStorage.CmdLines.PostMount
dst.Data.XFSStorage.CmdLines.PostActivate = src.Data.XFSStorage.CmdLines.PostMount
dst.Data.GFS2Storage.CmdLines.PostActivate = src.Data.GFS2Storage.CmdLines.PostMount
dst.Data.RawStorage.CmdLines.PreDeactivate = src.Data.RawStorage.CmdLines.PreUnmount
dst.Data.XFSStorage.CmdLines.PreDeactivate = src.Data.XFSStorage.CmdLines.PreUnmount
dst.Data.GFS2Storage.CmdLines.PreDeactivate = src.Data.GFS2Storage.CmdLines.PreUnmount

// Preserve Hub data on down-conversion except for metadata.
return utilconversion.MarshalData(src, dst)
}
Expand Down Expand Up @@ -599,3 +633,21 @@ func (src *NnfSystemStorageList) ConvertTo(dstRaw conversion.Hub) error {
func (dst *NnfSystemStorageList) ConvertFrom(srcRaw conversion.Hub) error {
return apierrors.NewMethodNotSupported(resource("NnfSystemStorageList"), "ConvertFrom")
}

// The conversion-gen tool dropped these from zz_generated.conversion.go to
// force us to acknowledge that we are addressing the conversion requirements.

// Convert_v1alpha3_NnfStorageProfileCmdLines_To_v1alpha4_NnfStorageProfileCmdLines is an autogenerated conversion function.
func Convert_v1alpha3_NnfStorageProfileCmdLines_To_v1alpha4_NnfStorageProfileCmdLines(in *NnfStorageProfileCmdLines, out *nnfv1alpha4.NnfStorageProfileCmdLines, s apiconversion.Scope) error {
return autoConvert_v1alpha3_NnfStorageProfileCmdLines_To_v1alpha4_NnfStorageProfileCmdLines(in, out, s)
}

// Convert_v1alpha4_NnfStorageProfileCmdLines_To_v1alpha3_NnfStorageProfileCmdLines is an autogenerated conversion function.
func Convert_v1alpha4_NnfStorageProfileCmdLines_To_v1alpha3_NnfStorageProfileCmdLines(in *nnfv1alpha4.NnfStorageProfileCmdLines, out *NnfStorageProfileCmdLines, s apiconversion.Scope) error {
return autoConvert_v1alpha4_NnfStorageProfileCmdLines_To_v1alpha3_NnfStorageProfileCmdLines(in, out, s)
}

// Convert_v1alpha4_NnfStorageProfileLustreCmdLines_To_v1alpha3_NnfStorageProfileLustreCmdLines is an autogenerated conversion function.
func Convert_v1alpha4_NnfStorageProfileLustreCmdLines_To_v1alpha3_NnfStorageProfileLustreCmdLines(in *nnfv1alpha4.NnfStorageProfileLustreCmdLines, out *NnfStorageProfileLustreCmdLines, s apiconversion.Scope) error {
return autoConvert_v1alpha4_NnfStorageProfileLustreCmdLines_To_v1alpha3_NnfStorageProfileLustreCmdLines(in, out, s)
}
Loading

0 comments on commit 17ac743

Please sign in to comment.