From 8a8e1eddef23e0ae5b121fc130bffa769cc76629 Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Wed, 10 Sep 2025 11:35:44 -0600 Subject: [PATCH] csi: allow csi controller pod to set host networking The ceph csi controller plugin did not have the capability to set host networking, in case the host networking is being enforced with ROOK_ENFORCE_HOST_NETWORK: true. Signed-off-by: Travis Nielsen (cherry picked from commit e294c280ed61224cbc6dd9c7540fd8d3650a9e9c) --- pkg/operator/ceph/csi/operator_driver.go | 3 +++ pkg/operator/ceph/csi/operator_driver_test.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) 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)