Merge pull request #16514 from subhamkrai/fix-csi-operator-lable

csi: add labels to the csi-operator driver pod
This commit is contained in:
Travis Nielsen authored and GitHub committed 2025-09-22 09:39:52 -05:00
commit 77d5be2215
2 files changed
+23

No files matched your search

+7
View File
@@ -83,6 +83,8 @@ func (r *ReconcileCSI) createOrUpdateRBDDriverResource(cluster cephv1.CephCluste
return err
}
spec.NodePlugin.Labels = CSIParam.CSIRBDPodLabels
spec.ControllerPlugin.Labels = CSIParam.CSIRBDPodLabels
rbdDriver := &csiopv1.Driver{
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
@@ -129,6 +131,9 @@ func (r *ReconcileCSI) createOrUpdateCephFSDriverResource(cluster cephv1.CephClu
return err
}
spec.NodePlugin.Labels = CSIParam.CSICephFSPodLabels
spec.ControllerPlugin.Labels = CSIParam.CSICephFSPodLabels
cephFsDriver := &csiopv1.Driver{
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
@@ -179,6 +184,8 @@ func (r *ReconcileCSI) createOrUpdateNFSDriverResource(cluster cephv1.CephCluste
if err != nil {
return err
}
spec.NodePlugin.Labels = CSIParam.CSINFSPodLabels
spec.ControllerPlugin.Labels = CSIParam.CSINFSPodLabels
NFSDriver := &csiopv1.Driver{
TypeMeta: metav1.TypeMeta{},
@@ -67,6 +67,10 @@ func TestReconcileCSI_createOrUpdateDriverResources(t *testing.T) {
},
}
CSIParam.CSIRBDPodLabels = map[string]string{"rbd-label": "rbd-value"}
CSIParam.CSICephFSPodLabels = map[string]string{"cephfs-label": "cephfs-value"}
CSIParam.CSINFSPodLabels = map[string]string{"nfs-label": "nfs-value"}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ns := "test"
@@ -153,13 +157,25 @@ func TestReconcileCSI_createOrUpdateDriverResources(t *testing.T) {
}
}
assert.Equal(t, "rbd-value", driver.Spec.ControllerPlugin.PodCommonSpec.Labels["rbd-label"])
assert.Equal(t, "rbd-value", driver.Spec.NodePlugin.PodCommonSpec.Labels["rbd-label"])
assert.NotEqualValues(t, "rbd-value", driver.Spec.NodePlugin.PodCommonSpec.Labels["cephfs-label"])
// Test CephFS driver
err = cl.Get(context.TODO(), types.NamespacedName{Name: fmt.Sprintf("%s.cephfs.csi.ceph.com", c.Namespace), Namespace: ns}, driver)
assert.NoError(t, err)
assert.Equal(t, "cephfs-value", driver.Spec.ControllerPlugin.PodCommonSpec.Labels["cephfs-label"])
assert.Equal(t, "cephfs-value", driver.Spec.NodePlugin.PodCommonSpec.Labels["cephfs-label"])
assert.NotEqualValues(t, "cephfs-value", driver.Spec.NodePlugin.PodCommonSpec.Labels["rbd-label"])
// Test NFS driver
err = cl.Get(context.TODO(), types.NamespacedName{Name: fmt.Sprintf("%s.nfs.csi.ceph.com", c.Namespace), Namespace: ns}, driver)
assert.NoError(t, err)
assert.Equal(t, "nfs-value", driver.Spec.ControllerPlugin.PodCommonSpec.Labels["nfs-label"])
assert.Equal(t, "nfs-value", driver.Spec.NodePlugin.PodCommonSpec.Labels["nfs-label"])
assert.NotEqualValues(t, "nfs-value", driver.Spec.NodePlugin.PodCommonSpec.Labels["rbd-label"])
})
}
}