diff --git a/cmd/stackit-csi-plugin/apko-base-image.yaml b/cmd/stackit-csi-plugin/apko-base-image.yaml index 9db9604e..f61a6b7d 100644 --- a/cmd/stackit-csi-plugin/apko-base-image.yaml +++ b/cmd/stackit-csi-plugin/apko-base-image.yaml @@ -6,20 +6,20 @@ contents: packages: - busybox # required by fsck.xfs as it is a sh script - ca-certificates - - blkid=~2.41.2 - - blockdev=~2.41.2 - - e2fsprogs=~1.47.3 - - e2fsprogs-extra=~1.47.3 - - lsblk=~2.41.2 - - mount=~2.41.2 - - umount=~2.41.2 - - btrfs-progs=~6.17 - - udev=~258.1 - - util-linux-misc=~2.41.2 # contains fsck - - xfsprogs=~6.17.0 - - xfsprogs-core=~6.17.0 - - xfsprogs-extra=~6.17.0 # contains xfs_io - - findmnt=~2.41.2 + - blkid=~2.42.2 + - blockdev=~2.42.2 + - btrfs-progs=~7.1 + - e2fsprogs=~1.47.4 + - e2fsprogs-extra=~1.47.4 + - lsblk=~2.42.2 + - mount=~2.42.2 + - umount=~2.42.2 + - udev=~261.2 + - util-linux-misc=~2.42.2 # contains fsck + - xfsprogs=~7.1.1 + - xfsprogs-core=~7.1.1 + - xfsprogs-extra=~7.1.1 # contains xfs_io + - findmnt=~2.42.2 accounts: run-as: root diff --git a/docs/csi-driver.md b/docs/csi-driver.md index ee448454..11c5b472 100644 --- a/docs/csi-driver.md +++ b/docs/csi-driver.md @@ -27,6 +27,14 @@ The CSI driver enables dynamic provisioning and management of persistent volumes ## Basic Usage +### Supported Filesystems + +We currently support the following file systems: + +- ext4 +- xfs +- [EXPERIMENTAL] btrfs. Use at your own risk! + ### Create a StorageClass ```YAML diff --git a/pkg/csi/blockstorage/nodeserver.go b/pkg/csi/blockstorage/nodeserver.go index 17501b5a..5b3cc838 100644 --- a/pkg/csi/blockstorage/nodeserver.go +++ b/pkg/csi/blockstorage/nodeserver.go @@ -39,6 +39,15 @@ import ( "github.com/stackitcloud/cloud-provider-stackit/pkg/stackit/metadata" ) +var ( + ValidFSTypes = map[string]struct{}{ + util.FSTypeExt3: {}, + util.FSTypeExt4: {}, + util.FSTypeXfs: {}, + util.FSTypeBtrfs: {}, + } +) + type nodeServer struct { Driver *Driver Mount mount.IMount @@ -199,12 +208,18 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol // Volume Mount if notMnt { // set default fstype is ext4 - fsType := "ext4" + fsType := util.FSTypeExt4 var options []string if mnt := volumeCapability.GetMount(); mnt != nil { if mnt.FsType != "" { fsType = mnt.FsType } + + _, ok := ValidFSTypes[strings.ToLower(fsType)] + if !ok { + return nil, status.Errorf(codes.InvalidArgument, "NodeStageVolume: invalid fstype %s. Only supported fsTypes are xfs or ext4 (default)", fsType) + } + mountFlags := mnt.GetMountFlags() options = append(options, collectMountOptions(fsType, mountFlags)...) } @@ -260,7 +275,15 @@ func validateNodeStageVolumeRequest(req *csi.NodeStageVolumeRequest) (stagingTar // If the initial mount fails, it rescans the device and retries the mount operation. func (ns *nodeServer) formatAndMountRetry(devicePath, stagingTarget, fsType string, options []string) error { m := ns.Mount - err := m.Mounter().FormatAndMount(devicePath, stagingTarget, fsType, options) + var err error + if fsType == util.FSTypeXfs { + // With newer xfsProgs version newer features are enabled by default. This forces mkfs.xfs to use flags compatible + // with the linux LTS 5.10 kernel + formatOptions := []string{"-n", "parent=0", "-i", "exchange=0,nrext64=0"} + err = m.Mounter().FormatAndMountSensitiveWithFormatOptions(devicePath, stagingTarget, fsType, options, nil, formatOptions) + } else { + err = m.Mounter().FormatAndMount(devicePath, stagingTarget, fsType, options) + } if err != nil { klog.Infof("Initial format and mount failed: %v. Attempting rescan.", err) // Attempting rescan if the initial mount fails @@ -495,7 +518,7 @@ func collectMountOptions(fsType string, mntFlags []string) []string { // By default, xfs does not allow mounting of two volumes with the same filesystem uuid. // Force ignore this uuid to be able to mount volume + its clone / restored snapshot on the same node. - if fsType == "xfs" { + if fsType == util.FSTypeXfs { options = append(options, "nouuid") } return options diff --git a/pkg/csi/util/util.go b/pkg/csi/util/util.go index f57f171b..ef29d42b 100644 --- a/pkg/csi/util/util.go +++ b/pkg/csi/util/util.go @@ -8,6 +8,13 @@ const ( TEBIBYTE ) +const ( + FSTypeExt3 = "ext3" + FSTypeExt4 = "ext4" + FSTypeXfs = "xfs" + FSTypeBtrfs = "btrfs" +) + // RoundUpSize calculates how many allocation units are needed to accommodate // a volume of given size. E.g. when user wants 1500MiB volume, while AWS EBS // allocates volumes in gibibyte-sized chunks, diff --git a/test/e2e/csi-plugin/block-storage.yaml b/test/e2e/csi-plugin/block-storage.yaml index 18e79095..14f691a2 100644 --- a/test/e2e/csi-plugin/block-storage.yaml +++ b/test/e2e/csi-plugin/block-storage.yaml @@ -4,6 +4,11 @@ SnapshotClass: FromExistingClassName: "stackit" DriverInfo: Name: block-storage.csi.stackit.cloud + SupportedFsType: + ext4: {} + xfs: {} + btrfs: {} + ext3: {} Capabilities: # whether to support RAW block mode block: true