From 9195bfb88719723f91488ebc3248723ca38d4788 Mon Sep 17 00:00:00 2001 From: Erickson Silva de Oliveira Date: Wed, 27 Dec 2023 11:14:28 -0300 Subject: [PATCH] Remove debug option from cephfs PVs Since version v3.9.0 of ceph-csi, the "debug" option has been removed from mountOptions of the cephfs storage class, however, this option still exists on cephfs PVs created with the previous version of ceph-csi, causing the pod to fail. To resolve this, a check for existing cephfs PVs has been added to the cephfs storage-init script to remove this parameter if it exists. Test Plan: PASS: Create a PVC and pod on AIO-SX with ceph-csi v3.6.2 PASS: Build platform-integ-apps with changes (ceph-csi v3.9.0) PASS: Check that "mountOption: -debug" is not present in the cephfs storage class and pv. Closes-Bug: 2047571 Change-Id: Id7c8f77d2bc0b4e4afc67966810d5d3c40fc1e06 Signed-off-by: Erickson Silva de Oliveira --- ...hfs-remove-mountoptions-debug-on-pvs.patch | 47 +++++++++++++++++++ .../debian/deb_folder/patches/series | 1 + 2 files changed, 48 insertions(+) create mode 100644 platform-helm/debian/deb_folder/patches/0017-ceph-csi-cephfs-remove-mountoptions-debug-on-pvs.patch diff --git a/platform-helm/debian/deb_folder/patches/0017-ceph-csi-cephfs-remove-mountoptions-debug-on-pvs.patch b/platform-helm/debian/deb_folder/patches/0017-ceph-csi-cephfs-remove-mountoptions-debug-on-pvs.patch new file mode 100644 index 0000000..ce6360d --- /dev/null +++ b/platform-helm/debian/deb_folder/patches/0017-ceph-csi-cephfs-remove-mountoptions-debug-on-pvs.patch @@ -0,0 +1,47 @@ +From b2ae5df05fb7f029336d8713f24825cdb121c641 Mon Sep 17 00:00:00 2001 +From: Erickson Silva de Oliveira +Date: Tue, 16 Jan 2024 12:10:38 -0300 +Subject: [PATCH] ceph-csi-cephfs: remove mountOptions debug on PVs + +Since ceph-csi v3.9.0, the "debug" option has been removed +from mountOptions of the cephfs storage class, however, +this option still exists on cephfs PVs created with the previous +version of ceph-csi, causing the pod to fail. + +To resolve this, a check for existing cephfs PVs has been added +to the cephfs storage-init script to remove this parameter if +it exists. + +Signed-off-by: Erickson Silva de Oliveira +--- + charts/ceph-csi-cephfs/templates/storage-init.yaml | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/charts/ceph-csi-cephfs/templates/storage-init.yaml b/charts/ceph-csi-cephfs/templates/storage-init.yaml +index dc47e0afc..6bcaf8b30 100644 +--- a/charts/ceph-csi-cephfs/templates/storage-init.yaml ++++ b/charts/ceph-csi-cephfs/templates/storage-init.yaml +@@ -147,6 +147,20 @@ data: + fi + } + ++ # Patch CephFS PVs when created from a version earlier than v3.9.0 of ceph-csi ++ # See: https://github.com/ceph/ceph-csi/issues/3927 ++ CEPHFS_PVS=$(kubectl get pv -o=jsonpath='{.items[?(@.spec.storageClassName=="cephfs")].metadata.name}' 2>/dev/null) ++ if [ -n "${CEPHFS_PVS}" ]; then ++ for PV in "${CEPHFS_PVS[@]}"; do ++ MOUNT_OPTIONS=$(kubectl get pv ${PV} -o jsonpath='{.spec.mountOptions}') ++ if [ -n "${MOUNT_OPTIONS}" ]; then ++ # The regex below removes the "debug" option (including the quotes) and also the comma if it exists before or after it ++ MOUNT_OPTIONS_WITHOUT_DEBUG=( `echo $MOUNT_OPTIONS | sed -E 's/\"debug\"\s*,?|,?\s*\"debug\"//g'` ) ++ kubectl patch pv "${PV}" --type=json -p="[{'op': 'add', 'path': '/spec/mountOptions','value':${MOUNT_OPTIONS_WITHOUT_DEBUG}}]" ++ fi ++ done ++ fi ++ + # Delete old driver if current fsGroupPolicy is different from "File" + # See: https://github.com/ceph/ceph-csi/issues/3397 + CURRENT_FS_GROUP_POLICY=$(kubectl describe csidriver "${CSI_DRIVER_NAME}" 2>/dev/null | grep -oP 'Fs Group Policy:\K.*' | tr -d ' ') +-- +2.34.1 + diff --git a/platform-helm/debian/deb_folder/patches/series b/platform-helm/debian/deb_folder/patches/series index c2f6f75..1b14b30 100644 --- a/platform-helm/debian/deb_folder/patches/series +++ b/platform-helm/debian/deb_folder/patches/series @@ -14,3 +14,4 @@ 0014-ceph-csi-cephfs-add-annotations-to-nodeplugin-daemonset.patch 0015-ceph-csi-cephfs-add-snapshotclass.patch 0016-ceph-csi-rbd-add-snapshotclass.patch +0017-ceph-csi-cephfs-remove-mountoptions-debug-on-pvs.patch