argoproj-labs / argocd-image-updater

Automatic container image update for Argo CD
https://argocd-image-updater.readthedocs.io/en/stable/
Apache License 2.0
1.28k stars 265 forks source link

Sequential Builds Overwriting Image Tags in Git Repository #712

Open ccpatrut opened 6 months ago

ccpatrut commented 6 months ago

Describe the bug I am encountering an issue with ArgoCD Image Updater when handling sequential builds that result in two different images. The write-back method is set to git, and it appears that there are two pushes: one to write the tag together with the image, followed by a second push which deletes the first commit content and updates the image to latest@sha256:.

To Reproduce Here are the relevant annotations for the ArgoCD application:


apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: example-service-dev
  annotations:
    argocd-image-updater.argoproj.io/write-back-method: git
    argocd-image-updater.argoproj.io/image-list: 'backend=docker.example.com/backend:feature-new-support,sender=docker.example.com/sender:feature-new-support'
    argocd-image-updater.argoproj.io/backend.helm.image-tag: backend.image.tag
    argocd-image-updater.argoproj.io/sender.helm.image-tag: sender.image.tag
    argocd-image-updater.argoproj.io/backend.helm.image-name: backend.image.repository
    argocd-image-updater.argoproj.io/sender.helm.image-name: sender.image.repository
    argocd-image-updater.argoproj.io/backend.update-strategy: digest
    argocd-image-updater.argoproj.io/sender.update-strategy: digest
  1. When two builds happen one after the other, it results in the following:
- name: sender.image.tag
  value: feature-new-support@sha256:ad689fe6aa78934c8e62a3456ba8492fc5b5e851a16e552e97e31f228bf6ffa7
  forcestring: true
  1. Followed by a commit:
    - name: sender.image.tag
    value: latest@sha256:ad689fe6aa78934c8e62a3456ba8492fc5b5e851a16e552e97e31f228bf6ffa7
    forcestring: true

Backend is also updated, the second push seems to overwrite the first commit content and update the image to latest@sha256: instead of maintaining the specific tag provided in the first commit.

Expected behavior • The image updater should respect the digest strategy and not overwrite the tag with latest. • Each commit should maintain its respective tag without being overwritten by subsequent commit

Additional context

Version 0.12.0

Logs Not relevant

chengfang commented 3 weeks ago

Do you still see this problem with recent versions like 0.15.0, 0.14.0? If so, can you please provide the initial content of the git write-back target file, after the first push, and after the 2nd push?