Argo-cd: Invalid value: 0x0: must be specified for an update

Created on 27 May 2020  路  4Comments  路  Source: argoproj/argo-cd

Describe the bug

Argo application SyncFailed with:

applications.argoproj.io "argocd" is invalid: metadata.resourceVersion: Invalid value: 0x0: must be specified for an update

The diff is showing that argocd wants to remove metadata of generation, selfLink, etc.

To Reproduce

A list of the steps required to reproduce the issue. Best of all, give us the URL to a repository that exhibits this issue.

https://github.com/hashbang/gitops/blob/master/argocd/applications/argocd.yaml

Expected behavior

Apply succeeds

Screenshots
Screenshot_2020-05-27_11-20-23
Screenshot_2020-05-27_11-22-24

Version

v1.5.5+0fdef48

bug buin-triage

Most helpful comment

Hello @daurnimator ,

I suspect this might happen because someone edited application resource using kubectl edit and kubectl.kubernetes.io/last-applied-configuration no longer valid.

Mixing imperative and declarative kubectl commands might cause inconsistent diff: https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/#how-to-update-objects

I suggest trying to remove kubectl.kubernetes.io/last-applied-configuration annotation from that application.

All 4 comments

Hello @daurnimator ,

I suspect this might happen because someone edited application resource using kubectl edit and kubectl.kubernetes.io/last-applied-configuration no longer valid.

Mixing imperative and declarative kubectl commands might cause inconsistent diff: https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/#how-to-update-objects

I suggest trying to remove kubectl.kubernetes.io/last-applied-configuration annotation from that application.

edited application resource using kubectl edit and kubectl.kubernetes.io/last-applied-configuration no longer valid.

Yes this appeared to be the issue: I manually edited the annotation to remove the extra fields and was able to get argocd to sync.

However, I don't think anyone manually applied those changes.... we did have a (Digital Ocean managed) cluster upgrade in the same time period: I wonder if they dump things out and feed them back in with kubectl apply?

We had a similar issues on a few resources; e.g. argocd wanted to delete all the local user secrets out of the argocd-secret.

Closing as I don't think we'll be able to replicate :(

It is solved by getting the existing resource version and add it to the update object before applying.

        getObj, err := dr.Get(obj.GetName(), metav1.GetOptions{})
        if errors.IsNotFound(err) {
            // This doesnt ever happen even if it is already deleted or not found
            log.Printf("%v not found", obj.GetName())
            return nil, nil
        }

        if err != nil {
            return nil, err
        }

        obj.SetResourceVersion(getObj.GetResourceVersion())

        response, err := dr.Update(obj, metav1.UpdateOptions{})
        if err != nil {
            return nil, err
        }


Was this page helpful?
0 / 5 - 0 ratings

Related issues

KarstenSiemer picture KarstenSiemer  路  3Comments

chiragthaker picture chiragthaker  路  3Comments

ksaito1125 picture ksaito1125  路  3Comments

peterbosalliandercom picture peterbosalliandercom  路  3Comments

clintberry picture clintberry  路  3Comments