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 <Erickson.SilvadeOliveira@windriver.com>
This commit is contained in:
Erickson Silva de Oliveira 2023-12-27 11:14:28 -03:00
parent 396dfb7d34
commit 9195bfb887
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,47 @@
From b2ae5df05fb7f029336d8713f24825cdb121c641 Mon Sep 17 00:00:00 2001
From: Erickson Silva de Oliveira <Erickson.SilvadeOliveira@windriver.com>
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 <Erickson.SilvadeOliveira@windriver.com>
---
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

View File

@ -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