diff --git a/pkg/operator/ceph/csi/operator_driver.go b/pkg/operator/ceph/csi/operator_driver.go index 3f065ef54..5ce7f097c 100644 --- a/pkg/operator/ceph/csi/operator_driver.go +++ b/pkg/operator/ceph/csi/operator_driver.go @@ -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{ diff --git a/pkg/operator/ceph/csi/operator_driver_test.go b/pkg/operator/ceph/csi/operator_driver_test.go index 9218a12f0..3b8ac7572 100644 --- a/pkg/operator/ceph/csi/operator_driver_test.go +++ b/pkg/operator/ceph/csi/operator_driver_test.go @@ -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)