#4764·argo-cd

Resources with custom `OwnerReference` not pruned when removed from manifests

Author: AmitBenAmiCreated Nov 5, 2020Updated Sep 16, 2026
Labelsenhancementcomponent:application-controller

Describe the bug

I'm using ArgoCD for deploying my applications on Kubernetes. I am using my own chart with CRDs I created: Host and Check CRDs. The chart templates both the Host and Check, in a way that a single values.yaml holds one Host resource and multiple Check resources. The logical hierarchy is that Host contains multiple Checks. In my custom controller for the CRDs, I set the OwnerReference of each Check to be its Host - after the resources were deployed to Kubernetes.

The problem is when I delete a specific Check from the Helm Chart's values.yaml, ArgoCD doesn't show that it is in a status of OutOfSync (requires pruning), but rather removes the resources status from the application. Also, the only actions available at all of this resource (which have custom OwnerReference is only Delete, but it doesn't have the Sync action (although it is from the Helm Chart).

To Reproduce

Since I'm using my own CRDs, the only way to reproduce is by using general Kubernetes resources. That can be done by creating a chart with 2 pods as resources:

  1. The first pod will be the father
  2. The second pod (the child pod) will have the father as OwnerReference

Flow:

  1. Add the father pod to the helm chart, and afterwards deploy from ArgoCD's application
  2. Add the child pod to the helm chart, and add the first pod deployed (the father) as its OwnerReference:
yaml
ownerReferences:
  - apiVersion: v1
    kind: Pod
    name: pod-father
    uid: <UID-of-father-pod>
  1. After adding the child pod to the chart, deploy it from ArgoCD's application. After deployment, the child pod should be "under" the father pod like in this picture: Screen Shot 2020-11-05 at 19 01 04

The child pod have Health and Status Screen Shot 2020-11-05 at 19 05 40

The child pod doesn't have the Sync action, but only the Delete action Screen Shot 2020-11-05 at 19 11 00

  1. Now, remove the child pod from the Chart, to see ArgoCD showing it as OutOfSync (requires pruning)
  2. After the removal, the child pod won't show the OutOfSync (requires pruning) status, but rather won't have any status at all (only Health), and the actions available is only Delete Screen Shot 2020-11-05 at 19 03 08 Screen Shot 2020-11-05 at 19 03 52 Screen Shot 2020-11-05 at 19 04 30

Expected behavior

Since the resources with the custom OwnerReference are also part of the Helm Chart, they should be handled as if they didn't have any OwnerReference, and whenever they get deleted from the Chart, they should be marked as OutOfSync (requires pruning) as well as the other resources. Furthermore, the also need to have the Sync action and not only Delete.

Version

ArgoCD version v1.7.6+b04c25e (Also can reproduce on version v1.6.1+159674e )

Kubernetes version 1.16.13

bash
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.6", GitCommit:"dff82dc0de47299ab66c83c626e08b245ab19037", GitTreeState:"clean", BuildDate:"2020-07-16T00:04:31Z", GoVersion:"go1.14.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"16+", GitVersion:"v1.16.13-eks-2ba888", GitCommit:"2ba888155c7f8093a1bc06e3336333fbdb27b3da", GitTreeState:"clean", BuildDate:"2020-07-17T18:48:53Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}