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.24k stars 256 forks source link

Image Updater reverts image to old tag with latest strategy #453

Open kahootali opened 2 years ago

kahootali commented 2 years ago

Describe the bug I am testing image-updater plugin with ArgoCD for our CD solution, I have used following annotations on my Argo app

    argocd-image-updater.argoproj.io/image-list: app=kahootali/nginx
    argocd-image-updater.argoproj.io/app.update-strategy: latest
    argocd-image-updater.argoproj.io/app.allow-tags: regexp:^[0-9]{6}-[0-9]{6}_RC$

I am using my nginx image based on default nginx:alpine image just for testing purposes...

https://hub.docker.com/r/kahootali/nginx/tags

The tags are using date & time for understanding which image was built when.

At first, I used the image tag 221506-164030 the plugin updated the image to 222406-162230_RC and pushed to git which is fine, but then I built the new image 222406-163830 and updated git manually with this new tag but the plugin again reverted to 222406-162230_RC which shouldn't be the case as the one I updated manually was built later than the one with _RC tag..

Expected behavior Argocd-image-updater shouldn't have updated the image to the previous tag as it matches the regex but should have checked whether the timestamp is greater as well , as the new tag can be a hotfix and I need to update it urgently..

Version

quay.io/argoprojlabs/argocd-image-updater:v0.12.0

Logs Used debug level logs

time="2022-06-24T11:45:44Z" level=debug msg="Considering this image for update" alias=app application=argotestapp-development image_name=kahootali/nginx image_tag=222406-163830 registry=
time="2022-06-24T11:45:44Z" level=debug msg="Using no version constraint when looking for a new tag" alias=app application=argotestapp-development image_name=kahootali/nginx image_tag=222406-163830 registry=
time="2022-06-24T11:45:45Z" level=debug msg="Cache hit for kahootali/nginx:222406-162230_RC" alias=app application=argotestapp-development image_name=kahootali/nginx image_tag=222406-163830 registry=
time="2022-06-24T11:45:45Z" level=debug msg="found 1 from 1 tags eligible for consideration" image="kahootali/nginx:222406-163830"
time="2022-06-24T11:45:45Z" level=info msg="Setting new image to kahootali/nginx:222406-162230_RC" alias=app application=argotestapp-development image_name=kahootali/nginx image_tag=222406-163830 registry=
time="2022-06-24T11:45:45Z" level=debug msg="target parameters: image-spec= image-name=application.deployment.image.repository, image-tag=application.deployment.image.tag" application=argotestapp-development image=kahootali/nginx
time="2022-06-24T11:45:45Z" level=info msg="Successfully updated image 'kahootali/nginx:222406-163830' to 'kahootali/nginx:222406-162230_RC', but pending spec update (dry run=false)" alias=app application=argotestapp-development image_name=kahootali/nginx image_tag=222406-163830 registry=
chris102994 commented 1 year ago

I'm experiencing a similar issue with a different versioning tag sequence. It seems like it sorts and installs alphabetically rather than based on newest.

My instance's tags are essentially $(semver)-$(short git hash) and as you know the hashes can change. Assuming semver stays the same if the newest hash starts with an a but the installed starts with a b it'll think it's already up to date.

ard1498 commented 3 months ago

Hi all, I am experiencing a similar issue with the image updater tool. @kahootali , has this been fixed yet? @chris102994 were you able to figure out a workaround for this? Thanks in advance for the help!!

davelowelarsson commented 2 months ago

I'm experiencing a similar issue but using argo-image-updater 0.14.0

Argo-image-updater is considering a two days old image as the "newest-build" (using harbor as registry)