Merge pull request #16463 from rook/mergify/bp/release-1.18/pr-16462

csi: Set host networking on the csi controller pod if host networking is enforced (backport #16462)
This commit is contained in:
Travis Nielsen authored and GitHub committed 2025-09-10 14:10:16 -06:00
commit 940a062cb7
2 files changed
+6 -1

No files matched your search

+3
View File
@@ -27,6 +27,7 @@ import (
"github.com/pkg/errors"
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
"github.com/rook/rook/pkg/operator/k8sutil"
v1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
@@ -253,6 +254,7 @@ func (r *ReconcileCSI) generateDriverSpec(cluster cephv1.CephCluster) (csiopv1.D
return csiopv1.DriverSpec{}, errors.Wrapf(err, "failed to create ceph-CSI operator config ImageSetConfigmap for CR %s", opConfigCRName)
}
controllerPluginHostNetwork := opcontroller.EnforceHostNetwork()
driverSpec := csiopv1.DriverSpec{
Log: &csiopv1.LogSpec{
Verbosity: int(CSIParam.LogLevel),
@@ -277,6 +279,7 @@ func (r *ReconcileCSI) generateDriverSpec(cluster cephv1.CephCluster) (csiopv1.D
EnableSeLinuxHostMount: &CSIParam.EnablePluginSelinuxHostMount,
},
ControllerPlugin: &csiopv1.ControllerPluginSpec{
HostNetwork: &controllerPluginHostNetwork,
PodCommonSpec: csiopv1.PodCommonSpec{
PrioritylClassName: &CSIParam.PluginPriorityClassName,
Affinity: &corev1.Affinity{
@@ -118,13 +118,15 @@ func TestReconcileCSI_createOrUpdateDriverResources(t *testing.T) {
c.SetName("testcluster")
c.NamespacedName()
cephv1.SetEnforceHostNetwork(true)
defer cephv1.SetEnforceHostNetwork(false)
err := r.createOrUpdateDriverResources(*cluster, c)
assert.NoError(t, err)
// Test RBD driver
err = cl.Get(context.TODO(), types.NamespacedName{Name: fmt.Sprintf("%s.rbd.csi.ceph.com", c.Namespace), Namespace: ns}, driver)
assert.NoError(t, err)
assert.True(t, *driver.Spec.ControllerPlugin.HostNetwork)
if tt.expectMultusAnnots {
// Verify that both NodePlugin and ControllerPlugin have Multus annotations
assert.Nil(t, driver.Spec.NodePlugin.PodCommonSpec.Annotations)