Repository: rook/rook
Pull request #15867 (2025-05-18 12:09:15)

csi: enable CSI Metadata Injection by Default
This PR sets CSI_ENABLE_METADATA to true by default in the Rook configuration, ensuring that the  `--setmetadata=true` flag is added to CSI nodeplugin pods

<!-- Thank you for contributing to Rook! -->

<!-- STEPS TO FOLLOW:
  1. Add a description of the changes (frequently the same as the commit description)
  2. Enter the issue number next to "Resolves #" below (if there is no tracking issue resolved, **remove that section**)
  3. Review our Contributing documentation at https://rook.io/docs/rook/latest/Contributing/development-flow/
  4. Follow the steps in the checklist below, starting with the **Commit Message Formatting**.
-->

<!-- Uncomment this section with the issue number if an issue is being resolved
**Issue resolved by this Pull Request:**
Resolves #
--->

**Checklist:**

- [ ] **Commit Message Formatting**: Commit titles and messages follow guidelines in the [developer guide](https://rook.io/docs/rook/latest/Contributing/development-flow/#commit-structure).
- [ ] Reviewed the developer guide on [Submitting a Pull Request](https://rook.io/docs/rook/latest/Contributing/development-flow/#submitting-a-pull-request)
- [ ] [Pending release notes](https://github.com/rook/rook/blob/master/PendingReleaseNotes.md) updated with breaking and/or notable changes for the next minor release.
- [ ] Documentation has been updated, if necessary.
- [ ] Unit tests have been added, if necessary.
- [ ] Integration tests have been added, if necessary.


Madhu-1: @OdedViner please fix the CI failure
sp98: @OdedViner  TestReconcileCSI_createOrUpdateOperatorConfig should be updated to reflect the new changes. 
OdedViner: > @OdedViner `TestReconcileCSI_createOrUpdateOperatorConfig` unit test should be updated to reflect the new changes.

Hi @sp98 ,
I am encountering an issue where TestReconcileCSI_createOrUpdateOperatorConfig passes successfully on my local machine, but it fails in the CI environment.

Here is the error log from the CI run:
```
=== RUN   TestReconcileCSI_createOrUpdateOperatorConfig
2025-05-18 12:12:12.672093 I | ceph-csi: Creating ceph-CSI operator config CR
2025-05-18 12:12:12.672146 I | ceph-csi: Successfully create imageSet cm rook-csi-operator-image-set-configmap for ceph-CSI operator-config CR "ceph-csi-operator-config"
2025-05-18 12:12:12.672185 I | ceph-csi: Successfully created ceph-CSI operator config CR "ceph-csi-operator-config"
    operator_config_test.go:90: 
        	Error Trace:	/home/runner/work/rook/rook/pkg/operator/ceph/csi/operator_config_test.go:90
        	Error:      	Not equal: 
        	            	expected: true
        	            	actual  : false
        	Test:       	TestReconcileCSI_createOrUpdateOperatorConfig
```

Pass on my PC:
```
Running tool: /usr/local/go/bin/go test -timeout 30s -run ^TestReconcileCSI_createOrUpdateOperatorConfig$ github.com/rook/rook/pkg/operator/ceph/csi

=== RUN   TestReconcileCSI_createOrUpdateOperatorConfig
2025-05-19 15:53:16.751271 I | ceph-csi: Creating ceph-CSI operator config CR
2025-05-19 15:53:16.751358 I | ceph-csi: Successfully create imageSet cm rook-csi-operator-image-set-configmap for ceph-CSI operator-config CR "ceph-csi-operator-config"
2025-05-19 15:53:16.751370 W | op-k8sutil: WARNING: attempting to load operator setting "CSI_PLUGIN_NODE_AFFINITY" before configmap is loaded
2025-05-19 15:53:16.751374 W | op-k8sutil: WARNING: attempting to load operator setting "CSI_PLUGIN_TOLERATIONS" before configmap is loaded
2025-05-19 15:53:16.751376 W | op-k8sutil: WARNING: attempting to load operator setting "CSI_PROVISIONER_NODE_AFFINITY" before configmap is loaded
2025-05-19 15:53:16.751377 W | op-k8sutil: WARNING: attempting to load operator setting "CSI_PROVISIONER_TOLERATIONS" before configmap is loaded
2025-05-19 15:53:16.751388 I | ceph-csi: Successfully created ceph-CSI operator config CR "ceph-csi-operator-config"
--- PASS: TestReconcileCSI_createOrUpdateOperatorConfig (0.00s)
PASS
```
![image](https://github.com/user-attachments/assets/96755d36-f11e-4c0a-87ca-e11830903ac9)

Do you have any idea why this inconsistency might happen between CI and local environments?


Patch:
diff --git a/pkg/operator/ceph/csi/csi.go b/pkg/operator/ceph/csi/csi.go
index 231c5c041..49752f3a9 100644
--- a/pkg/operator/ceph/csi/csi.go
+++ b/pkg/operator/ceph/csi/csi.go
@@ -172,9 +172,9 @@ func (r *ReconcileCSI) setParams() error {
 		CSIParam.EnableCSIEncryption = true
 	}
 
-	CSIParam.CSIEnableMetadata = false
-	if strings.EqualFold(k8sutil.GetOperatorSetting("CSI_ENABLE_METADATA", "false"), "true") {
-		CSIParam.CSIEnableMetadata = true
+	CSIParam.CSIEnableMetadata = true
+	if strings.EqualFold(k8sutil.GetOperatorSetting("CSI_ENABLE_METADATA", "true"), "false") {
+		CSIParam.CSIEnableMetadata = false
 	}
 
 	if strings.EqualFold(k8sutil.GetOperatorSetting("CSI_CEPHFS_PLUGIN_UPDATE_STRATEGY", rollingUpdate), onDelete) {


Test patch:
diff --git a/pkg/operator/ceph/csi/operator_config_test.go b/pkg/operator/ceph/csi/operator_config_test.go
index a260a628f..7f16139a6 100644
--- a/pkg/operator/ceph/csi/operator_config_test.go
+++ b/pkg/operator/ceph/csi/operator_config_test.go
@@ -87,5 +87,5 @@ func TestReconcileCSI_createOrUpdateOperatorConfig(t *testing.T) {
 
 	err = cl.Get(context.TODO(), types.NamespacedName{Name: opConfigCRName, Namespace: r.opConfig.OperatorNamespace}, opConfig)
 	assert.NoError(t, err)
-	assert.Equal(t, *opConfig.Spec.DriverSpecDefaults.EnableMetadata, false)
+	assert.Equal(t, *opConfig.Spec.DriverSpecDefaults.EnableMetadata, true)
 }