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

Git tags pointing to wrong hash #4231

Closed
pbecotte opened this issue Sep 1, 2020 · 8 comments · Fixed by #4538
Closed

Git tags pointing to wrong hash #4231

pbecotte opened this issue Sep 1, 2020 · 8 comments · Fixed by #4538
Assignees
Labels
bug Something isn't working cherry-pick/1.7 Candidate for cherry picking into the 1.7 release branch regression Bug is a regression, should be handled with high priority
Milestone

Comments

@pbecotte
Copy link

pbecotte commented Sep 1, 2020

Argocd Version: v1.7.2+c342d3f

Describe the bug

We have a number of deployments pinned to a git tag, and updated by moving the tag (the "Tag Tracking" strategy from the docs). Today, a number of our deployments started failing. We have actually been using ARGOCD_APP_REVISION in the manifests- when we build an image, we tag it with the git commit, and then when the tag is moved to that commit, we stick APP_REVISION in the image name.

We updated to 1.7.2 a couple days ago, and this is no longer working. ARGOCD_APP_REVISION now points to the hash of the tag instead of the commit. This means that our images which are tagged with the commit hash (before the tag is even created) are no longer being referenced. To understand that this is an issue in the engine somewhere, the link under "status" in the UI no longer works either (getting a github 404 since its trying to go to the tag hash instead of the commit hash)

To Reproduce

Create an application with target_revision = a tag name instead of a branch.

Expected behavior

The hash that comes up in the build environment ARGOCD_APP_REVISION should be the actual commit hash.

@pbecotte pbecotte added the bug Something isn't working label Sep 1, 2020
@jessesuen jessesuen added regression Bug is a regression, should be handled with high priority cherry-pick/1.7 Candidate for cherry picking into the 1.7 release branch labels Sep 1, 2020
@jannfis
Copy link
Member

jannfis commented Sep 2, 2020

Hi, to my knowledge, Git tags have no unique revision. They are simply pointers to any revision in the tree, unless they are annotated, in which case they will get their own revision - because the annotated tag is committed into the tree (without being recorded in the Git log, tho).

As an example in a freshly initialized repository with one commit and afterwards creating two tags, v0.0.1 is a lightweight tag, while v0.0.2 is an annotated tag (created using git tag -a):

$ git log
commit a81d319a5b262436eb5cda04740d19420b2ba235 (HEAD -> master, tag: v0.0.2, tag: v0.0.1)
Author: jannfis
Date:   Wed Sep 2 10:26:56 2020 +0200

    Initial commit
$ git rev-parse v0.0.1
a81d319a5b262436eb5cda04740d19420b2ba235
$ git rev-parse v0.0.2
b217fb20161144da7118fb668bee1b2f4adc7780

So I think it might be possible that you have used an annotated tag - which then resolves to a different revision, and ultimately leads to the behaviour you have described.

@pbecotte
Copy link
Author

pbecotte commented Sep 2, 2020

yes, it is an annotated tag. But, it has always been annotated tags- the jenkins script that creates them has not changed, but the argocd behavior has.

@abangser
Copy link

Argocd Version: v1.7.2+c342d3f

I am seeing this behaviour on v1.6.1+159674e. @pbecotte which version did you upgrade from? I am curious if we can track down if/where this may have been introduced.

@jessesuen jessesuen added this to the v1.8 milestone Sep 16, 2020
@gaganhegde
Copy link
Contributor

Will take a look into this @jessesuen

@pbecotte
Copy link
Author

We were on 1.4.2 before the upgrade

@jaideepr97
Copy link
Contributor

jaideepr97 commented Oct 2, 2020

Hi @pbecotte
Do you mind sharing an example for how/where you're using ARGOCD_APP_REVISION in your manifests? Might help trace and reproduce the problem

@abangser
Copy link

abangser commented Oct 3, 2020

Thanks for looking into this! In my case we have a helm chart and are overriding a value.

E.g. having an Argo Application with:

spec:
  source:
    helm:
      valueFiles:
        - values.yaml
      parameters:
        - name: commit_sha
          value: $ARGOCD_APP_REVISION

and then a values.yaml with:

commit_sha: SET_BY_ARGO

which then gets templated into a deployment manifest as the image tag like:

apiVersion: app/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
        - image: {{ .Values.imageBase }}:{{ .Values.commit_sha }}

@jaideepr97
Copy link
Contributor

Thanks for providing context @abangser, I think I've been able to reproduce the issue locally
working on a fix now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cherry-pick/1.7 Candidate for cherry picking into the 1.7 release branch regression Bug is a regression, should be handled with high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants