-
Notifications
You must be signed in to change notification settings - Fork 16
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
Delete Cluster Scoped Resources #92
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,10 +234,32 @@ func (r *Reconciler) handleEventingDeletion(ctx context.Context, eventing *event | |
eventing, err, log) | ||
} | ||
} | ||
eventing.Status.SetSubscriptionManagerReadyConditionToFalse( | ||
eventingv1alpha1.ConditionReasonEventMeshSubManagerStopped, | ||
eventingv1alpha1.ConditionSubscriptionManagerStoppedMessage) | ||
|
||
// delete cluster-scoped resources, such as clusterrole and clusterrolebinding. | ||
if err := r.deleteClusterScopedResources(ctx, eventing); err != nil { | ||
return ctrl.Result{}, r.syncStatusWithPublisherProxyErrWithReason(ctx, | ||
eventingv1alpha1.ConditionReasonDeletedFailed, eventing, err, log) | ||
} | ||
eventing.Status.SetPublisherProxyConditionToFalse( | ||
eventingv1alpha1.ConditionReasonDeleted, | ||
eventingv1alpha1.ConditionPublisherProxyDeletedMessage) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this function be covered in the unit test as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you mean the function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry, no, I meant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems there is no unit test yet. Deletion is covered with Integration Tests. |
||
return r.removeFinalizer(ctx, eventing) | ||
} | ||
|
||
// deleteClusterScopedResources deletes cluster-scoped resources, such as clusterrole and clusterrolebinding. | ||
// K8s doesn't support cleaning cluster-scoped resources owned by namespace-scoped resources: | ||
// https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/#owner-references-in-object-specifications | ||
grischperl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
func (r *Reconciler) deleteClusterScopedResources(ctx context.Context, eventingCR *eventingv1alpha1.Eventing) error { | ||
if err := r.kubeClient.DeleteClusterRole(ctx, eventing.GetPublisherClusterRoleName(*eventingCR), eventingCR.Namespace); err != nil { | ||
return err | ||
} | ||
return r.kubeClient.DeleteClusterRoleBinding(ctx, eventing.GetPublisherClusterRoleBindingName(*eventingCR), eventingCR.Namespace) | ||
} | ||
|
||
func (r *Reconciler) handleEventingReconcile(ctx context.Context, | ||
eventing *eventingv1alpha1.Eventing, log *zap.SugaredLogger) (ctrl.Result, error) { | ||
log.Info("handling Eventing reconciliation...") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ConditionReason for all other cases is
EventMeshSubscriptionManager<something>
. For the sake of consistency, can we haveEventMeshSubscriptionManagerStopped
here?Otherwise, if none of them need to be EventMesh specific, can the other reasons have that part removed, so it can be reused for NATS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reason stopped is actually common for NATS and EventMesh. Thus, changed to general name.