argo-cd icon indicating copy to clipboard operation
argo-cd copied to clipboard

Ignoring Extraneous Resources doesn't improve app's overall sync status

Open jfroche opened this issue 5 years ago • 36 comments

Describe the bug

We configure our openshift identity providers resources using argocd. Extra Secrets are created in the openshift-authentication namespace by the operator. We followed https://argoproj.github.io/argo-cd/user-guide/compare-options/#ignoring-resources-that-are-extraneous to ignore these secrets but our Application keeps being marked as "OutOfSync".

As you can see in the screenshot bellow the status the resource are correctly ignored but the application keeps being in OutOfSync.

To Reproduce

Here is our argocd application yaml:

---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: idp
  namespace: argocd
  annotations:
    argocd.argoproj.io/compare-options: IgnoreExtraneous
    argocd.argoproj.io/sync-options: Prune=false
spec:
  destination:
    namespace: default
    server: https://kubernetes.default.svc
  project: cicd
  source:
    path: sbx/application/idp
    plugin:
      name: encrypted-yaml
    repoURL: http://<our internal repo>/projects.git
    targetRevision: cicd
  syncPolicy:
    automated:
      prune: false
      selfHeal: false

Here is our idp configuration:

---
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
  name: cluster
spec:
  identityProviders:
    - name: local_accounts
      mappingMethod: claim
      type: HTPasswd
      htpasswd:
        fileData:
          name: htpass-users
    - name: Active_Directory
      mappingMethod: claim
      type: LDAP
      ldap:
        attributes:
          id:
            - dn
          email:
            - mail
          name:
            - cn
          preferredUsername:
            - sAMAccountName
        bindDN: "<redacted>"
        bindPassword:
          name: ad-secret
        insecure: true
        url: "ldap://<redacted>?sAMAccountName"

Expected behavior

The project should be marked as in sync.

Screenshots

Here is a screenshot of the project: image

Here is a screenshot of the sync status: image

Version

argocd: v1.6.1+159674e
  BuildDate: 2020-06-19T00:39:46Z
  GitCommit: 159674ee844a378fb98fe297006bf7b83a6e32d2
  GitTreeState: clean
  GoVersion: go1.14.1
  Compiler: gc
  Platform: linux/amd64

Logs

Hitting refresh, here is the logs from the application controller:

time="2020-10-05T16:17:15Z" level=info msg="Refreshing app status (normal refresh requested), level (2)" application=idp
time="2020-10-05T16:17:15Z" level=info msg="Refreshing app status (controller refresh requested), level (1)" application=cicd-applications
time="2020-10-05T16:17:15Z" level=info msg="Comparing app state (cluster: https://kubernetes.default.svc, namespace: default)" application=idp
time="2020-10-05T16:17:16Z" level=info msg="getRepoObjs stats" application=idp build_options_ms=0 helm_ms=0 plugins_ms=0 repo_ms=0 time_ms=77 unmarshal_ms=76 version_ms=0
time="2020-10-05T16:17:16Z" level=info msg="Skipping auto-sync: need to prune extra resources only but automated prune is disabled" application=idp
time="2020-10-05T16:17:16Z" level=info msg="Update successful" application=idp
time="2020-10-05T16:17:16Z" level=info msg="Reconciliation completed" application=idp dedup_ms=0 dest-namespace=default dest-server="https://kubernetes.default.svc" diff_ms=3 fields.level=2 git_ms=77 health_ms=0 live_ms=1 settings_ms=0 sync_ms=0 time_ms=97

Thank you for you help !

jfroche avatar Oct 05 '20 16:10 jfroche

Is there actually anything in the app diff?

jannfis avatar Oct 05 '20 17:10 jannfis

Yes the app diff contains the two extraneous secrets. Here is the application diff: image

Here is the diff of one of the extraneous secret: image

jfroche avatar Oct 05 '20 19:10 jfroche

These annotations are supposed to be put on the resources you want to ignore and avoid pruning (i.e. the Secrets), not on the application spec.

  annotations:
    argocd.argoproj.io/compare-options: IgnoreExtraneous
    argocd.argoproj.io/sync-options: Prune=false

How did these resources end up with the Argo CD tracking label? Were they at one point deployed using Argo CD?

jessesuen avatar Oct 05 '20 21:10 jessesuen

The extra resources are created by the operator so we have no control on their content (they are recreated by openshift if we try to remove them). Is there a way to exclude them in argocd from the application as we have no control on their content ?

I will do maybe a PR to improve the documentation because This can be done by adding this annotation:in https://argoproj.github.io/argo-cd/user-guide/compare-options/#ignoring-resources-that-are-extraneous doesn't tell us where to add these annotations

jfroche avatar Oct 05 '20 21:10 jfroche

Any news on the issue apart from changing the docs? Experiencing the same with OCP 4.5 oauth + console customizations

reggie-k avatar Nov 26 '20 19:11 reggie-k

I think that for such resources, that are being created without user's control (kustomize is still a case of user control, but redhat operators aren't), the option should be available on the argo-app itself. Probably something like :

    syncPolicy:
      ignoreExtraneous:
         resourceNameRegex: <some regex matching the resource name>
         namespace: <the namespace name, as in those cases it differs from the targetNamespace of the app>

reggie-k avatar Nov 26 '20 19:11 reggie-k

These annotations are supposed to be put on the resources you want to ignore and avoid pruning (i.e. the Secrets), not on the application spec.

  annotations:
    argocd.argoproj.io/compare-options: IgnoreExtraneous
    argocd.argoproj.io/sync-options: Prune=false

How did these resources end up with the Argo CD tracking label? Were they at one point deployed using Argo CD?

Argo app manages a user-created secret. Redhat operator copies that secret to another namespace and renames it, but copies the original secret along with the label that Argocd puts on it :-) So, from Argocd's point of view, the openshift-managed secret was created by it as well (though not true). I can raise an issue with redhat, I guess, as well, and ask to stop copying the labels from the original resource, but they might have a legit explanation for such a behavior. So, like I mentioned above, I think Argo app spec should have an option to exclude such resources

reggie-k avatar Nov 26 '20 20:11 reggie-k

Yes, would also like an option to exclude a resource entirely. In this case they are resources created by helm from an application that defines a helm chart via the k3s HelmChart CRD ...

ignoreDifferences but without the jsonPointers basically ... or a functioning root (/) jsonPointer ... ?

  ignoreDifferences:
  - group: core
    kind: Secret
    name: concourse-postgresql
    jsonPointers:
    - /

frimik avatar Dec 25 '20 22:12 frimik

Currently trying to get argocd to manage itself without using kustomize. I was hopeful that ignoreDifferences on the app would have allowed us to generate the configmap elsewhere along with maybe adding sync-options: Prune=false on the resource itself. Without implementing kustomize I don't see a way around this (but open to ideas?). I suspect it would be easier to implement an application specific ignoreDifferences than break out the argocd-cm cr into its formal parts (repositories cr, oidc cr etc) which would also be great.

tsunamishaun avatar Mar 02 '21 20:03 tsunamishaun

I am running into a similar issue with Confluent's Operator for Kafka and related services.

Their operator creates some services and configmaps that Argo (understandably so) tries to prune, however, these resources are crucial for the functioning of our software.

Given that these resources are not part of the repo itself, is there any way to flag them so that Argo won't try to prune them? The approach of adding labels to each individual resources doesn't seem to apply here, given that a new service per replica is spun up

Screenshot_2021-03-17 Argo CD - Applications schema-registry

dkravetz avatar Mar 17 '21 10:03 dkravetz

I was wondering, do these operators actually set an ownerReferences on the resources they create?

jannfis avatar Mar 17 '21 11:03 jannfis

At least openshift oauth cr does not have an owner reference On Wed, Mar 17, 2021, 13:28 jannfis @.***> wrote:

I was wondering, do these operators actually set an ownerReferences on the resources they create?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/argoproj/argo-cd/issues/4487#issuecomment-801007266, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVDWBGN5D3ALAX5ZB7UPH3TECG4HANCNFSM4SE5J6CA .

reggie-k avatar Mar 18 '21 10:03 reggie-k

I was wondering, do these operators actually set an ownerReferences on the resources they create?

Not that I can see, but they do have the following labels:

  labels:
    argocd.argoproj.io/instance: schema-registry
    component: schemaregistry

dkravetz avatar Mar 22 '21 12:03 dkravetz

We just ran into this same problem with the Strimzi.io Kafka Operator (slack thread https://argoproj.slack.com/archives/CASHNF6MS/p1616683667362100). There needs to be a way to have Argo completely ignore a resource and just not show it to us. :/

diranged avatar Mar 25 '21 16:03 diranged

We just ran into this same problem with the Strimzi.io Kafka Operator (slack thread https://argoproj.slack.com/archives/CASHNF6MS/p1616683667362100). There needs to be a way to have Argo completely ignore a resource and just not show it to us. :/

I would personally prefer to see the resources, just not have the UI showing the need to prune this resources. After all, they are part of the Application, so I would assume that it's a better fitting use case to see the resources, just not have them affect the sync status

dkravetz avatar Mar 26 '21 15:03 dkravetz

Same issue with victoriametrics operator, Argocd marks resources created by operator as "OutOfSync (requires pruning)" this are sa, cr, crb, psp

rayman-g avatar Apr 07 '21 07:04 rayman-g

Creating the original secrets with the IgnoreExtranous compare-option seems to be a valid workaround for the openshift-config related secrets:

The annotation is copied to the v4-0-config-user-idp-1-bind-password secret in theopenshift-authentication namespace, so the compare option is now effective on both itself and the declared secret (ad-secret in openshift-config). Unfortunately, this breaks purging of openshift-config secrets that are no longer used. Probably deleting it manually, is acceptable given that identity providers should not change too often.

---
apiVersion: v1
kind: Secret
metadata:
  annotations:
    argocd.argoproj.io/compare-options: IgnoreExtraneous
    description: Bind password to access AD
  name: ad-secret
  namespace: openshift-config
type: Opaque
data:
  bindPassword: KioqKg==

timspeetjens avatar May 12 '21 13:05 timspeetjens

Works for me

On Wed, May 12, 2021, 16:55 Tim Speetjens @.***> wrote:

Creating the original secrets with the IgnoreExtranous compare-option seems to be a valid workaround for the openshift-config related secrets:

The annotation is copied to the v4-0-config-user-idp-1-bind-password secret in theopenshift-authentication namespace, so the compare option is now effective on both itself and the declared secret (ad-secret in openshift-config). Unfortunately, this breaks purging of openshift-config secrets that are no longer used. Probably deleting it manually, is acceptable given that identity providers should not change too often.

---apiVersion: v1kind: Secretmetadata: annotations: argocd.argoproj.io/compare-options: IgnoreExtraneous description: Bind password to access AD name: ad-secret namespace: openshift-configtype: Opaquedata: bindPassword: KioqKg==

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/argoproj/argo-cd/issues/4487#issuecomment-839792534, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVDWBDCADMIMBRLNFXRLHTTNKCEJANCNFSM4SE5J6CA .

reggie-k avatar May 12 '21 14:05 reggie-k

RHBZ https://bugzilla.redhat.com/show_bug.cgi?id=1960651

timspeetjens avatar May 26 '21 06:05 timspeetjens

Possible solution to this: #6324

jannfis avatar May 26 '21 07:05 jannfis

Hi, Any update?

"Possible solution to this: #6324"

I had trouble finding what the workaround is for making argocd not to track these extra resources created by openshift operators ...

Thanks ...

EDIT: So to clarify, the resources have argocd.argoproj.io/compare-options: IgnoreExtraneous and this fixes the SyncStatus issue. They are however still visible in "App Diff" which is confusing.

gorantornqvist avatar Nov 03 '21 14:11 gorantornqvist

I've also just encountered this issue when deploying the cert-manager operator on Argo 2.1.2.

gurnben avatar Dec 16 '21 02:12 gurnben

I think that for such resources, that are being created without user's control (kustomize is still a case of user control, but redhat operators aren't), the option should be available on the argo-app itself. Probably something like :

    syncPolicy:
      ignoreExtraneous:
         resourceNameRegex: <some regex matching the resource name>
         namespace: <the namespace name, as in those cases it differs from the targetNamespace of the app>

Hey @reggie-k , I can't find resourceNameRegex option in the code or the documentation. Are you sure this works?

vikas027 avatar May 18 '22 02:05 vikas027

It was a proposal, not an implemented feature

fadecore avatar May 18 '22 12:05 fadecore

It was a proposal, not an implemented feature

Ah, my bad. I need new glasses :(

vikas027 avatar May 19 '22 01:05 vikas027

@jessesuen you removed the bug and added works-for-me label, I believe this is neither a bug nor a works-for-me situation, it's rather a feature or enhancement request. What do you think?

aschaber1 avatar May 19 '22 04:05 aschaber1

Since this issue was first created, we have a new annotation-based resource tracking mechanism that will help us identify resources that are offshoots of managed resources and allow us to decide not to prune them. Please follow this issue:

https://github.com/argoproj/argo-cd/issues/8683#issuecomment-1111605207

jessesuen avatar May 19 '22 05:05 jessesuen

I think that for such resources, that are being created without user's control (kustomize is still a case of user control, but redhat operators aren't), the option should be available on the argo-app itself. Probably something like :

    syncPolicy:
      ignoreExtraneous:
         resourceNameRegex: <some regex matching the resource name>
         namespace: <the namespace name, as in those cases it differs from the targetNamespace of the app>

Hey @reggie-k , I can't find resourceNameRegex option in the code or the documentation. Are you sure this works?

As pointed out above, this was a proposal. But what does work for me, is setting the two annotations on the original resource I manage in git:

 annotations:
    argocd.argoproj.io/compare-options: IgnoreExtraneous
    argocd.argoproj.io/sync-options: Prune=false

Then, the resource created by operator (the unmanaged one, the one that is created by the operator from the original one in git) becomes yellow (as requires pruning), but the application itself is green and synced.

reggie-k avatar May 19 '22 05:05 reggie-k

Is there a way to hide the ignored resources in the interface as well?

The two annotations

      argocd.argoproj.io/compare-options: IgnoreExtraneous
      argocd.argoproj.io/sync-options: Prune=false

work very well. Resources created by the operator are not deleted/synchronized during the synchronization process.

However, the resources still appear in the interface and make the application very confusing. 2022-06-14 12_44_48-

RSBlek avatar Jun 14 '22 10:06 RSBlek

We ran into this issue here while using ArgoCD to manage OpenShift authentication configuration. We create a configmap holding a CA Certificate and a secret holding some credentials, those get copied by OpenShift operators and ArgoCD finds the copies and thinks it manages them. The IgnoreExtraneous helps, but I really wish I could make the copies just not appear at all somehow.

jkupferer avatar May 09 '23 12:05 jkupferer