csi: use new flag to enable VGS feature

In the Alpha Version of the VolumeGroupSnapshot
Feature the flag to enable the feature was
`--enable-volume-group-snapshots=true` and in the beta
API the feature is diasbled by default to enable it
we need to set `--feature-gate=CSIVolumeGroupSnapshot=true`

There is a change in the flag between the API version
This PR add a code where we choose the required
flag based on the API version.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 279e5f7cac)
This commit is contained in:
Madhu Rajanna authored and Travis Nielsen committed 2024-12-10 09:54:13 -07:00
1 parent 34de55717f
commit fd12192dd4
5 files changed
+28 -8

No files matched your search

+24 -4
View File
@@ -303,15 +303,35 @@ func (r *ReconcileCSI) setParams() error {
CSIParam.DriverNamePrefix = k8sutil.GetValue(r.opConfig.Parameters, "CSI_DRIVER_NAME_PREFIX", r.opConfig.OperatorNamespace)
_, err = r.context.ApiExtensionsClient.ApiextensionsV1().CustomResourceDefinitions().Get(context.TODO(), "volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io", metav1.GetOptions{})
crd, err := r.context.ApiExtensionsClient.ApiextensionsV1().CustomResourceDefinitions().Get(context.TODO(), "volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io", metav1.GetOptions{})
if err != nil && !kerrors.IsNotFound(err) {
return errors.Wrapf(err, "failed to get volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io CRD")
}
CSIParam.VolumeGroupSnapshotSupported = (err == nil)
CSIParam.EnableVolumeGroupSnapshot = true
if strings.EqualFold(k8sutil.GetValue(r.opConfig.Parameters, "CSI_ENABLE_VOLUME_GROUP_SNAPSHOT", "true"), "false") {
CSIParam.EnableVolumeGroupSnapshot = false
if err == nil && len(crd.Spec.Versions) > 0 {
ver := crd.Spec.Versions[0]
// Determine if VolumeGroupSnapshot feature should be disabled
disableVGS := strings.EqualFold(k8sutil.GetValue(r.opConfig.Parameters, "CSI_ENABLE_VOLUME_GROUP_SNAPSHOT", "true"), "false")
const (
enableVolumeGroupSnapshotFlag = "--enable-volume-group-snapshots="
featureGateFlag = "--feature-gate=CSIVolumeGroupSnapshot="
)
// Check for "v1alpha1" version to determine the appropriate CLI flag
// In the "v1alpha1" version, we use the '--enable-volume-group-snapshots' flag.
// In later versions (e.g., "v1beta1"), we use the '--feature-gate=CSIVolumeGroupSnapshot' flag.
if ver.Name == "v1alpha1" {
CSIParam.VolumeGroupSnapshotCLIFlag = enableVolumeGroupSnapshotFlag + "true"
} else {
CSIParam.VolumeGroupSnapshotCLIFlag = featureGateFlag + "true"
}
if disableVGS {
if ver.Name == "v1alpha1" {
CSIParam.VolumeGroupSnapshotCLIFlag = enableVolumeGroupSnapshotFlag + "false"
} else {
CSIParam.VolumeGroupSnapshotCLIFlag = featureGateFlag + "false"
}
}
}
kubeApiBurst := k8sutil.GetValue(r.opConfig.Parameters, "CSI_KUBE_API_BURST", "")
+1 -1
View File
@@ -139,7 +139,7 @@ func (r *ReconcileCSI) createOrUpdateCephFSDriverResource(cluster cephv1.CephClu
}
cephFsDriver.Spec.SnapshotPolicy = csiopv1a1.NoneSnapshotPolicy
if CSIParam.EnableVolumeGroupSnapshot {
if CSIParam.VolumeGroupSnapshotCLIFlag != "" {
cephFsDriver.Spec.SnapshotPolicy = csiopv1a1.VolumeGroupSnapshotPolicy
}
+1 -1
View File
@@ -77,8 +77,8 @@ type Param struct {
CephFSAttachRequired bool
RBDAttachRequired bool
NFSAttachRequired bool
VolumeGroupSnapshotCLIFlag string
VolumeGroupSnapshotSupported bool
EnableVolumeGroupSnapshot bool
LogLevel uint8
SidecarLogLevel uint8
CephFSLivenessMetricsPort uint16
@@ -63,7 +63,7 @@ spec:
- "--leader-election-retry-period={{ .LeaderElectionRetryPeriod }}"
- "--extra-create-metadata=true"
{{ if .VolumeGroupSnapshotSupported }}
- "--enable-volume-group-snapshots={{ .EnableVolumeGroupSnapshot }}"
- "{{ .VolumeGroupSnapshotCLIFlag }}"
{{ end }}
{{ if .KubeApiBurst }}
- "--kube-api-burst={{ .KubeApiBurst }}"
@@ -120,7 +120,7 @@ spec:
- "--leader-election-retry-period={{ .LeaderElectionRetryPeriod }}"
- "--extra-create-metadata=true"
{{ if .VolumeGroupSnapshotSupported }}
- "--enable-volume-group-snapshots={{ .EnableVolumeGroupSnapshot }}"
- "{{ .VolumeGroupSnapshotCLIFlag }}"
{{ end }}
{{ if .KubeApiBurst }}
- "--kube-api-burst={{ .KubeApiBurst }}"