Skip to content

Commit

Permalink
Merge pull request #464 from openshift-cherrypick-robot/cherry-pick-4…
Browse files Browse the repository at this point in the history
…62-to-release-4.16

Bug 2304074:[release-4.16] controllers: delete the webhook created by the ocs-client-operator
  • Loading branch information
openshift-merge-bot[bot] authored Aug 30, 2024
2 parents 50b6f1c + fe90ac2 commit d4c6adf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bundle/manifests/odf-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ spec:
- patch
- update
- watch
- apiGroups:
- admissionregistration.k8s.io
resources:
- validatingwebhookconfigurations
verbs:
- delete
- apiGroups:
- apiextensions.k8s.io
resources:
Expand Down
6 changes: 6 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ rules:
- patch
- update
- watch
- apiGroups:
- admissionregistration.k8s.io
resources:
- validatingwebhookconfigurations
verbs:
- delete
- apiGroups:
- apiextensions.k8s.io
resources:
Expand Down
1 change: 1 addition & 0 deletions controllers/storagesystem_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type StorageSystemReconciler struct {
//+kubebuilder:rbac:groups=operators.coreos.com,resources=subscriptions/finalizers,verbs=update
//+kubebuilder:rbac:groups=console.openshift.io,resources=consolequickstarts,verbs=get;list;create;update;delete
//+kubebuilder:rbac:groups=apiextensions.k8s.io,resources=customresourcedefinitions,verbs=get;list;watch;create;update
//+kubebuilder:rbac:groups=admissionregistration.k8s.io,resources=validatingwebhookconfigurations,verbs=delete

// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
Expand Down
11 changes: 11 additions & 0 deletions controllers/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"strings"

"go.uber.org/multierr"
admv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -354,6 +355,16 @@ func EnsureVendorCsv(cli client.Client, csvName string) (*operatorv1alpha1.Clust
for i := range csvObj.Spec.InstallStrategy.StrategySpec.DeploymentSpecs {
csvObj.Spec.InstallStrategy.StrategySpec.DeploymentSpecs[i].Spec.Replicas = &replicas
}

if replicas == 0 {
// delete the subscription webhook created by the ocs-client-operator
// we can not delete the webhook by the ocs-client-operator itself because the client operator is down
webhook := &admv1.ValidatingWebhookConfiguration{}
webhook.Name = "subscription.ocs.openshift.io"
if err = cli.Delete(context.TODO(), webhook); err != nil && !errors.IsNotFound(err) {
return err
}
}
}

return SetOdfSubControllerReference(cli, csvObj)
Expand Down

0 comments on commit d4c6adf

Please sign in to comment.