Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Remove finalizer to avoid finalize loop in GitHubSource FinalizeKind(). #1089

Merged
merged 2 commits into from
Apr 1, 2020
Merged
Changes from 1 commit
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: 6 additions & 4 deletions github/pkg/reconciler/githubsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, source *sourcesv1alpha1.G
if err != nil {
source.Status.MarkNoSecrets("AccessTokenNotFound", "%s", err)
tom24d marked this conversation as resolved.
Show resolved Hide resolved
controller.GetEventRecorder(ctx).Eventf(source, corev1.EventTypeWarning,
"FailedFinalize", "Could not delete webhook %q: %v", source.Status.WebhookIDKey, err)
return err
"WebhookDeletionSkipped", "Could not delete webhook %q: %v", source.Status.WebhookIDKey, err)
// return EventTypeNormal to avoid finalize loop
return pkgreconciler.NewEvent(corev1.EventTypeNormal, "WebhookDeletionSkipped", "Could not delete webhook %q: %v", source.Status.WebhookIDKey, err)
}

args := &webhookArgs{
Expand All @@ -186,8 +187,9 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, source *sourcesv1alpha1.G
// Delete the webhook using the access token and stored webhook ID
err = r.deleteWebhook(ctx, args)
if err != nil {
tom24d marked this conversation as resolved.
Show resolved Hide resolved
controller.GetEventRecorder(ctx).Eventf(source, corev1.EventTypeWarning, "FailedFinalize", "Could not delete webhook %q: %v", source.Status.WebhookIDKey, err)
return err
controller.GetEventRecorder(ctx).Eventf(source, corev1.EventTypeWarning, "WebhookDeletionSkipped", "Could not delete webhook %q: %v", source.Status.WebhookIDKey, err)
// return EventTypeNormal to avoid finalize loop
return pkgreconciler.NewEvent(corev1.EventTypeNormal, "WebhookDeletionSkipped", "Could not delete webhook %q: %v", source.Status.WebhookIDKey, err)
}
// Webhook deleted, clear ID
source.Status.WebhookIDKey = ""
Expand Down