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

Bug 1732214: Fix panic when binding already exists #964

Merged
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
10 changes: 8 additions & 2 deletions pkg/controller/operators/catalog/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,10 @@ func (o *Operator) ExecutePlan(plan *v1alpha1.InstallPlan) error {
_, err = o.OpClient.KubernetesInterface().RbacV1().ClusterRoles().Create(&cr)
if k8serrors.IsAlreadyExists(err) {
// if we're updating, point owner to the newest csv
cr.Labels[ownerutil.OwnerKey] = step.Resolving
if cr.ObjectMeta.Labels == nil {
cr.ObjectMeta.Labels = map[string]string{}
}
cr.ObjectMeta.Labels[ownerutil.OwnerKey] = step.Resolving
_, err = o.OpClient.UpdateClusterRole(&cr)
if err != nil {
return errorwrap.Wrapf(err, "error updating clusterrole %s", cr.GetName())
Expand All @@ -1184,7 +1187,10 @@ func (o *Operator) ExecutePlan(plan *v1alpha1.InstallPlan) error {
// Attempt to create the ClusterRoleBinding.
_, err = o.OpClient.KubernetesInterface().RbacV1().ClusterRoleBindings().Create(&rb)
if k8serrors.IsAlreadyExists(err) {
rb.Labels[ownerutil.OwnerKey] = step.Resolving
if rb.ObjectMeta.Labels == nil {
rb.ObjectMeta.Labels = map[string]string{}
}
rb.ObjectMeta.Labels[ownerutil.OwnerKey] = step.Resolving
_, err = o.OpClient.UpdateClusterRoleBinding(&rb)
if err != nil {
return errorwrap.Wrapf(err, "error updating clusterrolebinding %s", rb.GetName())
Expand Down