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

FinalizeKind is overkill for IMC dispatcher #4509

Closed
mattmoor opened this issue Nov 12, 2020 · 3 comments · Fixed by #4511
Closed

FinalizeKind is overkill for IMC dispatcher #4509

mattmoor opened this issue Nov 12, 2020 · 3 comments · Fixed by #4511
Assignees
Labels
area/channels kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@mattmoor
Copy link
Member

Describe the bug

Today the IMC Dispatcher uses finalizers:

func (r *Reconciler) FinalizeKind(ctx context.Context, imc *v1.InMemoryChannel) reconciler.Event {
if imc.Status.Address != nil &&
imc.Status.Address.URL != nil {
if hostName := imc.Status.Address.URL.Host; hostName != "" {
logging.FromContext(ctx).Info("Removing dispatcher")
r.multiChannelMessageHandler.DeleteChannelHandler(hostName)
}
}
return nil
}

Expected behavior

When everything is in-memory, it makes more sense to actually do this kind of work directly in the informer callback rather than effectively blocking resource deletion on finalizer handling.

Knative release version

HEAD

Additional context

Due to the awkward handling of Finalizers on CRDs in Kubernetes, we should (IMO) limit our use of them to where it's absolutely needed, otherwise uninstall gets needlessly complex.

cc @vaikas

@mattmoor mattmoor added the kind/bug Categorizes issue or PR as related to a bug. label Nov 12, 2020
@vaikas vaikas self-assigned this Nov 12, 2020
@Cynocracy
Copy link
Contributor

Cynocracy commented Nov 12, 2020 via email

@mattmoor
Copy link
Member Author

Essentially if you uninstall CRD-based systems (incl. CRD + controller) that make use of finalizers while instances of those resources still exist what will happen is:

  1. CRD will be deleted (resources exist, so tombstoned)
  2. Controller will be deleted
  3. Instance of the tombstoned CRD will be marked for deletion

Now we're in trouble. The instances have finalizers, but the controller responsible for handling the removal of those finalizers is gone. So the CRD and those instance will sit around basically forever.


But wait! There's more...

If you reinstall things in this bad state, then things will seem fine at first, but what's really happening is:

  1. CRDs are applied (the tombstoned one exists).
  2. Controller comes up
  3. Controller processes tombstoned resources
  4. CRD is finally deleted
  5. Controller is not processing an unknown resource

But the fun doesn't stop there. Conversion webhooks exacerbate this further because you can't simply kubectl edit the resource to remove the finalizers because it has to go through the webhook which is (you guessed it) also gone.

So now you have to hand-edit the CRDs to remove the webhook, then hand-edit the instances to remove finalizers. Then everything finally goes away...

Luckily I think we only have the first two here 😅

@Cynocracy
Copy link
Contributor

Cynocracy commented Nov 12, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/channels kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants