Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

controllers: enforce host NW configuration on CSI controller plugin pods #271

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22.5
replace (
github.com/portworx/sched-ops => github.com/portworx/sched-ops v0.20.4-openstorage-rc3 // required by Rook v1.12
github.com/red-hat-storage/ocs-client-operator/api => ./api
github.com/red-hat-storage/ocs-operator/services/provider/api/v4 => ../ocs-operator/services/provider/api/
vbom.ml/util => github.com/fvbommel/util v0.0.0-20180919145318-efcd4e0f9787
)

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,6 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/ramendr/ramen/api v0.0.0-20241001141243-29d6f22ad237 h1:ig6ePD0yopC5Qi5BRmhsIsKaOkdsGXTSmG3HTYIpquo=
github.com/ramendr/ramen/api v0.0.0-20241001141243-29d6f22ad237/go.mod h1:nO6VM/+PEhcPGyFIQJdhY6ip822cA61PAy/s6IjenAA=
github.com/red-hat-storage/ocs-operator/services/provider/api/v4 v4.0.0-20241015071140-98c8184c6eec h1:M64BdwKMV3jKxcRsZiaGbRKsvlbhRGVZgcb4V/MFeWk=
github.com/red-hat-storage/ocs-operator/services/provider/api/v4 v4.0.0-20241015071140-98c8184c6eec/go.mod h1:t9GJk69TGXABBF8fFPB+ImpbA9mJyRS86wW6+Qn8xHo=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
Expand Down
14 changes: 14 additions & 0 deletions internal/controller/operatorconfigmap_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,20 @@ func (c *OperatorConfigMapReconciler) reconcileDelegatedCSI() error {
return fmt.Errorf("failed to reconcile csi operator config: %v", err)
}

// check for annotation to enforce host network on csi
storageClients := v1alpha1.StorageClientList{}
if err := c.list(&storageClients, &client.ListOptions{}); err != nil {
return fmt.Errorf("failed to get storage client: %v", err)
}

for i := 0; i < len(storageClients.Items); i++ {
enforceCSIHostNW, exists := storageClients.Items[i].Annotations[EnforceCSIHostNWAnnotationKey]
if exists && enforceCSIHostNW == "true" {
c.log.Info("enforce csi functional")
// csiOperatorConfig.Spec.DriverSpecDefaults.ControllerPlugin.HostNetwork = exists
}
}

// ceph rbd driver config
rbdDriver := &csiopv1a1.Driver{}
rbdDriver.Name = templates.RBDDriverName
Expand Down
6 changes: 6 additions & 0 deletions internal/controller/storageclient_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const (
storageClientFinalizer = "storageclient.ocs.openshift.io"
storageClaimProcessedAnnotationKey = "ocs.openshift.io/storageclaim.processed"
storageClientDefaultAnnotationKey = "ocs.openshift.io/storageclient.default"
EnforceCSIHostNWAnnotationKey = "ocs.openshift.io/enforce-csi-host-nw"

// indexes for caching
ownerIndexName = "index:ownerUID"
Expand Down Expand Up @@ -423,6 +424,11 @@ func (r *StorageClientReconciler) onboardConsumer(externalClusterClient *provide

r.storageClient.Status.ConsumerID = response.StorageConsumerUUID
r.storageClient.Status.Phase = v1alpha1.StorageClientOnboarding
if utils.AddAnnotation(r.storageClient, EnforceCSIHostNWAnnotationKey, fmt.Sprint(response.EnforceCSIHostNW)) {
if err := r.update(r.storageClient); err != nil {
return reconcile.Result{}, fmt.Errorf("failed to update StorageClient with desired config hash annotation: %v", err)
}
}

r.Log.Info("onboarding started")
return reconcile.Result{Requeue: true}, nil
Expand Down
Loading