argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
18.06k stars 5.52k forks source link

Namespace gets deleted immediately after sync #8821

Open AlekseyUsov opened 2 years ago

AlekseyUsov commented 2 years ago

Checklist:

Describe the bug

My woes started when I checked Replace in the app that manages compliance operator for OpenShift in an attempt to fix an unrelated issue, which led to openshift-compliance namespace getting stuck in Terminating state due to non-cleared finalizers. I removed them manually, as suggested here (I know, not the best approach, but I was out of options). That helped and the namespace disappeared, but now every time I try to sync the app so that it can create the namespace and dependent resources, ArgoCD just deletes it immediately after creating it. I tried creating it manually and noticed that it gets removed only when it has app.kubernetes.io/instance label set. Any ideas?

Expected behavior

I expect the namespace to get created, followed by all namespace-bound resources.

Logs There is namespaces "openshift-compliance" not found message in the application logs for every dependent object, which makes sense as they all expect a namespace to reside in.

Version

argocd: v2.1.2+unknown
  BuildDate: 2021-10-27T13:19:31Z
  GitCommit:
  GitTreeState: clean
  GoVersion: go1.16.6
  Compiler: gc
  Platform: linux/amd64
argocd-server: v2.1.2+unknown
  BuildDate: 2021-10-27T13:19:31Z
  GitTreeState: clean
  GoVersion: go1.16.6
  Compiler: gc
  Platform: linux/amd64
  Ksonnet Version: unable to determine ksonnet version: exec: "ks": executable file not found in $PATH
  Kustomize Version: v4.2.0 1970-01-01T00:00:00Z
  Helm Version: v3.6.0+gd095be9
  Kubectl Version: v0.21.0
  Jsonnet Version: v0.17.0
nikhleshgoenka commented 2 years ago

**When I'm trying to sync all apps it deletes the namespace for me too!! Though in ArgoCD logs there is no symptom of delete namespace being called by any application, is it due to Replace being used in all the apps?

{ "Version": "v2.2.9+38755a4", "BuildDate": "2022-05-18T12:02:28Z", "GitCommit": "38755a4c1e5232aa2e6f80c062593c9f07da0757", "GitTreeState": "clean", "GoVersion": "go1.16.11", "Compiler": "gc", "Platform": "linux/amd64", "KsonnetVersion": "v0.13.1", "KustomizeVersion": "v4.2.0 2021-06-30T22:49:26Z", "HelmVersion": "v3.7.1+g1d11fcb", "KubectlVersion": "v0.22.2", "JsonnetVersion": "v0.17.0" }**