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

Operator is removed before ressource when application is deleted causing deletion deadlock #9296

Closed
nneram opened this issue May 4, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@nneram
Copy link

nneram commented May 4, 2022

Describe the bug

I have an application that deploys an operator for Keycloak that creates and sync resources. This operator handle custom resources deletion with finalizer.

My problem is when I want to delete the application, the operator and the resources are deleted in the same time, so no one is removing finalizer from the resources and they stay. As a result, the application is looping in Deletion state. When you remove the finalizer by hand it delete the application well.

image
image

As you can see, the 3 resources have a finalize and k8s waits for it to be clean deleted by the operator which has been removed from the cluster.

I used both foreground and background deletion and also try to put annotation on the operator:

argocd.argoproj.io/sync-options: PruneLast=true

These solutions didn't make it work.

To Reproduce

Create an application that deploys an operator, custom resources definition and some resources that have deletion handles by operator. (Using finalizer)
Then request a deletion of this application; It will stay in deletion state while resources will be waiting for a clean removing from the operator.

Expected behavior

Wait for the operator to delete resources that are managed by it or delete operator at the last.

Version

argocd: v2.3.3+07ac038
  BuildDate: 2022-03-30T01:46:59Z
  GitCommit: 07ac038a8f97a93b401e824550f0505400a8c84e
  GitTreeState: clean
  GoVersion: go1.17.6
  Compiler: gc
  Platform: linux/amd64
WARN[0000] Failed to invoke grpc call. Use flag --grpc-web in grpc calls. To avoid this warning message, use flag --grpc-web.
argocd-server: v2.2.5+8f981cc
  BuildDate: 2022-02-05T01:33:25Z
  GitCommit: 8f981ccfcf942a9eb00bc466649f8499ba0455f5
  GitTreeState: clean
  GoVersion: go1.16.11
  Compiler: gc
  Platform: linux/amd64
  Ksonnet Version: v0.13.1
  Kustomize Version: v4.2.0 2021-06-30T22:49:26Z
  Helm Version: v3.7.1+g1d11fcb
  Kubectl Version: v0.22.2
  Jsonnet Version: v0.17.0
@nneram nneram added the bug Something isn't working label May 4, 2022
@nneram
Copy link
Author

nneram commented May 4, 2022

#7575

@alexec
Copy link
Contributor

alexec commented May 20, 2022

Could you try to work-around this using sync waves? I.e. put the controller into an earlier wave than the resource. When an app is deleted, resources should be delete in the reverse sync wave order. That should mean the controller is delete after the resource it needs to finalizer.

@nneram
Copy link
Author

nneram commented May 31, 2022

Hi @alexec, 😃

Indeed using sync waves annotation seems to work 👍🏻

If I choose the operator to be deleted at the end, it will be applied first and wait for other resources to be deployed and never become healthy so I was also stuck in first sync-wave.

I added an annotation on custom resources so they can be deleted earlier:
Custom resources:

metadata:
  annotations:
    argocd.argoproj.io/sync-wave: "1" 

This work fine, thank you for you help 💯

@jgato
Copy link

jgato commented Jan 2, 2023

I had similar issue, but in my case, the ArgoCD APP contains a Namespace and some other resources. So, when deleting, the NS deletion has to wait for the other objects to be deleted. Actually, one of them would take even some minutes.
Using sync-waves seems not be working, I have objects with waves higher than the NS. I would expect the NS to be deleted the last.
We dont delete the APP, we delete all the objects inside. And the NS is deleted immediately, the same than all the other objects.
The objects inside the APP are generated by a Kustomization generator, would this be changing the way waves are managed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants