argocd-image-updater
argocd-image-updater copied to clipboard
Regex not correctly parsed
Describe the bug We have a running argocd image updater. The Docker images in the repo are tagged with:
- int-5
- int-1635498622500 (this tag is the oldest in this repo)
The application config looks like:
argocd-image-updater.argoproj.io/image-list: appA=<Host to Repo>:int, appB=<Host to Repo>:int
argocd-image-updater.argoproj.io/appA.helm.image-tag: appA.image.tag
argocd-image-updater.argoproj.io/appB.helm.image-tag: appB.image.tag
argocd-image-updater.argoproj.io/appA.update-strategy: latest
argocd-image-updater.argoproj.io/appA.allow-tags: regexp:^int-.*$
argocd-image-updater.argoproj.io/appB.update-strategy: latest
argocd-image-updater.argoproj.io/appB.allow-tags: regexp:^int-.*$
argocd-image-updater.argoproj.io/appA.helm.image-name: appA.image.name
argocd-image-updater.argoproj.io/appB.helm.image-name: appB.image.name
argocd-image-updater.argoproj.io/git-branch: master
argocd-image-updater.argoproj.io/write-back-method: git
With the allow-tag set to regexp:^int-.*$ argocd image updater only uses/consideres int-5 and not the newer int-1635498622500 tag.
As soon as i change to regexp:^int-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$ the int-1635498622500 tag was used.
Why is the regex regexp:^int-.*$ not working here?
I already tested with an regex tester and it is definetly a valid and correct regex.
Version 0.11.0
If I understand you correctly, then this is expected behavior:
- You use update strategy
latest, which specifies to update to the image that has been most recently built int-5is newer thanint-1635498622500- Using
regexp:^int.*$as tag selector will match both tags - Image Updater will pick
int-5as being the newest image - If using
regexp:^int-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$as tag selector,int-5will be ignored and thereforeint-1635498622500will be chosen as the most recent tag
Why would you want to update to int-1635498622500, if int-5 is the more recent one?
I see some contrary information above. You say:
int-1635498622500 (this tag is the oldest in this repo)
and later
argocd image updater only uses/consideres int-5 and not the newer int-1635498622500 tag
It is worth noting that we can only determine the date when the image was built, not when it was tagged or pushed to the repository.
Hi @jannfis i think you did missunderstand my explanations.
int-1635498622500 is newer in the mean of build timestamp than int-5.
int-1635498622500 was build and pushed today and int-5 was build and pushed weeks ago.
Our issue was, that int-5 was used even int-1635498622500 was newer.
OK, if int-1635498622500 is newer than int-5, then probably there's something odd.
Are you able to increase log level to trace and submit the logs?
I have tried to reproduce it locally, building dummy images with the same tags, pushing them to a local registry and then ran argocd-image-updater test against it. The result was as expected, tho:
$ ./dist/argocd-image-updater test 10.42.0.1:30000/test-image \
--registries-conf test/e2e/assets/registries.conf \
--update-strategy latest \
--loglevel trace \
--allow-tags 'regexp:^int-.*$'
INFO[0000] getting image image_name=test-image registry="10.42.0.1:30000"
DEBU[0000] rate limit for https://10.42.0.1:30000 is 2147483647
INFO[0000] Loaded 1 registry configurations from test/e2e/assets/registries.conf
INFO[0000] Fetching available tags and metadata from registry image_name=test-image
TRAC[0000] https://10.42.0.1:30000/v2/test-image/tags/list
TRAC[0000] Getting manifest for image test-image:int-5 (operation 1/2)
TRAC[0000] acquired metadata semaphore
TRAC[0000] Getting manifest for image test-image:int-1635498622500 (operation 2/2)
TRAC[0000] acquired metadata semaphore
TRAC[0000] https://10.42.0.1:30000/v2/test-image/manifests/int-5
TRAC[0000] https://10.42.0.1:30000/v2/test-image/manifests/int-1635498622500
TRAC[0000] https://10.42.0.1:30000/v2/test-image/blobs/sha256:8e09dcb218e4f130d583296049b8ff7bfcf82718f5773354e9e7072c27359227
TRAC[0000] https://10.42.0.1:30000/v2/test-image/blobs/sha256:1e70a089125c571b75d95792394f7dda29a57389b087bc2fbcfed3bd7e34ba42
TRAC[0000] v2 SHA digest is sha256:c1fe998ffe877b48d49a3754a3fb94c816d0ce310c137f5fc5801aa3cacfd7d0
TRAC[0000] Found date 2021-10-29 13:30:39.536604867 +0000 UTC
TRAC[0000] released semaphore and terminated waitgroup
TRAC[0000] v2 SHA digest is sha256:f3bfc848cade3533156e972d0609730596c003ea86996535ad0bd20e990ed3d8
TRAC[0000] Found date 2021-10-29 13:31:01.314452111 +0000 UTC
TRAC[0000] released semaphore and terminated waitgroup
INFO[0000] Found 2 tags in registry image_name=test-image
TRAC[0000] Finding out whether to consider int-5 for being updateable image="10.42.0.1:30000/test-image"
TRAC[0000] Finding out whether to consider int-1635498622500 for being updateable image="10.42.0.1:30000/test-image"
DEBU[0000] found 2 from 2 tags eligible for consideration image="10.42.0.1:30000/test-image"
INFO[0000] latest image according to constraint is 10.42.0.1:30000/test-image:int-1635498622500