From 5093d411be1ffac4f4b13d3165c42e9541d3462f Mon Sep 17 00:00:00 2001 From: Jeff Roche Date: Wed, 10 May 2023 10:36:21 -0400 Subject: [PATCH] feat: ext4 support --- api/v1alpha1/lvmcluster_types.go | 11 +++++++++++ bundle/manifests/lvm.topolvm.io_lvmclusters.yaml | 4 ++++ .../lvms-operator.clusterserviceversion.yaml | 1 + config/crd/bases/lvm.topolvm.io_lvmclusters.yaml | 4 ++++ config/samples/lvm_v1alpha1_lvmcluster.yaml | 1 + controllers/constants.go | 3 --- controllers/topolvm_storageclass.go | 3 ++- ext4steps.txt | 13 +++++++++++++ 8 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 ext4steps.txt diff --git a/api/v1alpha1/lvmcluster_types.go b/api/v1alpha1/lvmcluster_types.go index 21089ef7d..096715949 100644 --- a/api/v1alpha1/lvmcluster_types.go +++ b/api/v1alpha1/lvmcluster_types.go @@ -58,6 +58,13 @@ type ThinPoolConfig struct { OverprovisionRatio int `json:"overprovisionRatio"` } +type DeviceFilesystemType string + +const ( + FilesystemTypeExt4 DeviceFilesystemType = "ext4" + FilesystemTypeXFS DeviceFilesystemType = "xfs" +) + type DeviceClass struct { // Name of the class, the VG and possibly the storageclass. // Validations to confirm that this field can be used as metadata.name field in storageclass @@ -88,6 +95,10 @@ type DeviceClass struct { // Default is a flag to indicate whether the device-class is the default // +optional Default bool `json:"default,omitempty"` + + // FilesystemType sets the filesystem the device should use + // +optional + FilesystemType DeviceFilesystemType `json:"fstype,omitempty"` } // DeviceSelector specifies the list of criteria that have to match before a device is assigned diff --git a/bundle/manifests/lvm.topolvm.io_lvmclusters.yaml b/bundle/manifests/lvm.topolvm.io_lvmclusters.yaml index 6ab6be3f3..625f4fe1e 100644 --- a/bundle/manifests/lvm.topolvm.io_lvmclusters.yaml +++ b/bundle/manifests/lvm.topolvm.io_lvmclusters.yaml @@ -65,6 +65,10 @@ spec: type: string type: array type: object + fstype: + description: FilesystemType sets the filesystem the device + should use + type: string name: description: 'Name of the class, the VG and possibly the storageclass. Validations to confirm that this field can diff --git a/bundle/manifests/lvms-operator.clusterserviceversion.yaml b/bundle/manifests/lvms-operator.clusterserviceversion.yaml index 1a1199a79..a85d34e2a 100644 --- a/bundle/manifests/lvms-operator.clusterserviceversion.yaml +++ b/bundle/manifests/lvms-operator.clusterserviceversion.yaml @@ -15,6 +15,7 @@ metadata: "deviceClasses": [ { "default": true, + "fstype": "xfs", "name": "vg1", "thinPoolConfig": { "name": "thin-pool-1", diff --git a/config/crd/bases/lvm.topolvm.io_lvmclusters.yaml b/config/crd/bases/lvm.topolvm.io_lvmclusters.yaml index 1d4b68ffa..93963f13e 100644 --- a/config/crd/bases/lvm.topolvm.io_lvmclusters.yaml +++ b/config/crd/bases/lvm.topolvm.io_lvmclusters.yaml @@ -63,6 +63,10 @@ spec: type: string type: array type: object + fstype: + description: FilesystemType sets the filesystem the device + should use + type: string name: description: 'Name of the class, the VG and possibly the storageclass. Validations to confirm that this field can diff --git a/config/samples/lvm_v1alpha1_lvmcluster.yaml b/config/samples/lvm_v1alpha1_lvmcluster.yaml index f4ed91473..89dd5bffa 100644 --- a/config/samples/lvm_v1alpha1_lvmcluster.yaml +++ b/config/samples/lvm_v1alpha1_lvmcluster.yaml @@ -11,3 +11,4 @@ spec: name: thin-pool-1 sizePercent: 90 overprovisionRatio: 10 + fstype: xfs diff --git a/controllers/constants.go b/controllers/constants.go index 60d5b1a0e..fce9f51cf 100644 --- a/controllers/constants.go +++ b/controllers/constants.go @@ -87,9 +87,6 @@ const ( DefaultLVMdSocket = "/run/lvmd/lvmd.sock" DeviceClassKey = "topolvm.io/device-class" - // default fstype for topolvm storage classes - TopolvmFilesystemType = "xfs" - // name of the lvm-operator container LVMOperatorContainerName = "manager" diff --git a/controllers/topolvm_storageclass.go b/controllers/topolvm_storageclass.go index bfc6ca19a..f96a9dc43 100644 --- a/controllers/topolvm_storageclass.go +++ b/controllers/topolvm_storageclass.go @@ -123,6 +123,7 @@ func getTopolvmStorageClasses(r *LVMClusterReconciler, ctx context.Context, lvmC sc := []*storagev1.StorageClass{} for _, deviceClass := range lvmCluster.Spec.Storage.DeviceClasses { scName := getStorageClassName(deviceClass.Name) + storageClass := &storagev1.StorageClass{ ObjectMeta: metav1.ObjectMeta{ Name: scName, @@ -135,7 +136,7 @@ func getTopolvmStorageClasses(r *LVMClusterReconciler, ctx context.Context, lvmC AllowVolumeExpansion: &allowVolumeExpansion, Parameters: map[string]string{ DeviceClassKey: deviceClass.Name, - "csi.storage.k8s.io/fstype": TopolvmFilesystemType, + "csi.storage.k8s.io/fstype": string(deviceClass.FilesystemType), }, } // reconcile will pick up any existing LVMO storage classes as well diff --git a/ext4steps.txt b/ext4steps.txt new file mode 100644 index 000000000..c8b88fdf9 --- /dev/null +++ b/ext4steps.txt @@ -0,0 +1,13 @@ +- build +- push +- deploy +- `oc project openshift-storage` +- create the cluster which specifies ext4 (config/samples/lvm_v1alpha1_lvmcluster.yaml) +- `oc get pods -w` until all are ready +- `oc get lvmclusters.lvm.topolvm.io my-lvmcluster -w` until ready +- `oc describe storageclass/lvms-vg1` to validate the Parameter "csi.storage.k8s.io/fstype=ext4" +- Create the pvc and pod (README) +- `oc debug pod/{pod name}` +- `chroot /host` +- `lvdisplay` to get the lv path +- `file -L -s {lv_path}` should have xfs or ext4 in the output \ No newline at end of file