Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions cmd/stackit-csi-plugin/apko-base-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions docs/csi-driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ The CSI driver enables dynamic provisioning and management of persistent volumes

## Basic Usage

### Supported Filesystems

We currently support the following file systems:

- ext3
- ext4 (default)
- xfs
- [EXPERIMENTAL] btrfs. Use at your own risk!

### Create a StorageClass

```YAML
Expand Down
29 changes: 26 additions & 3 deletions pkg/csi/blockstorage/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)...)
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions pkg/csi/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/csi-plugin/block-storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ SnapshotClass:
FromExistingClassName: "stackit"
DriverInfo:
Name: block-storage.csi.stackit.cloud
SupportedFsType:
ext4: {}
xfs: {}
ext3: {}
Capabilities:
# whether to support RAW block mode
block: true
Expand Down