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

Multiple aliases with same image #75

Closed
hawksight opened this issue Aug 27, 2020 · 6 comments
Closed

Multiple aliases with same image #75

hawksight opened this issue Aug 27, 2020 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@hawksight
Copy link

Describe the bug
When specifying multiple images to update via the annotation with two of those images as the same docker image but for different containers in your k8s deployment. Image Updater seems to update only one instance of the image.

It does not seem to update the second alias.

To Reproduce
Using this feature here, create an application with two image to update.

Here is my example from our own Django helm chart:

argocd-image-updater.argoproj.io/image-list: asfalia=gcr.io/sopost-k8s/asfalia:~v0.1.0-0, celery=gcr.io/sopost-k8s/asfalia:~v0.1.0-0
argocd-image-updater.argoproj.io/asfalia.update-strategy: latest
argocd-image-updater.argoproj.io/asfalia.helm.image-name: image.repository
argocd-image-updater.argoproj.io/asfalia.helm.image-tag: image.tag
argocd-image-updater.argoproj.io/celery.update-strategy: latest
argocd-image-updater.argoproj.io/celery.helm.image-name: celery.image.repository
argocd-image-updater.argoproj.io/celery.helm.image-tag: celery.image.tag

What i find is the container (aso alias) asfalia does get updated. But the celery container / alias does not.

Here are my helm values input for reference:

image:
  repository: gcr.io/sopost-k8s/asfalia
  tag: ""
  pullPolicy: Always
celery:
  # When enabled, ensure all values are as expected
  enabled: false
  image:
    repository: gcr.io/sopost-k8s/asfalia
    tag: ""
    pullPolicy: IfNotPresent

Expected behavior

Both containers should be updated at the same time when a new image is pushed to the docker registry.

Additional context

Here are some logs showing that the image-updater is aware of the image but only seems to update one of the containers.

time="2020-08-27T09:59:05Z" level=info msg="Successfully updated image 'gcr.io/sopost-k8s/asfalia:v0.1.0-e46d4ba4a7ff398a387b28722332bb821cbf7129' to 'gcr.io/sopost-k8s/asfalia:v0.1.0-b5941f2ec8cb05590f1160bbae1a7ab25f943381'" application=ops-eu-asfalia image_name=sopost-k8s/asfalia image_tag=v0.1.0-e46d4ba4a7ff398a387b28722332bb821cbf7129 registry=gcr.io
time="2020-08-27T09:59:05Z" level=info msg="Processing results: applications=2 images_considered=3 images_updated=1 errors=0"

It would be helpful if in the log output, it showed the alias name too, so you know from the log which container would have been updated.

Version
v0.4.0

Logs

See above.
Also some images in the UI showing only the main image / tag was overridden:

celery is not updated.
Screenshot from 2020-08-27 11-22-18

asfalia is updated
Screenshot from 2020-08-27 11-22-01

@jannfis
Copy link
Contributor

jannfis commented Aug 27, 2020

Thanks!

There was indeed a logic flaw in how the images are handled. Should be fixed with #76, which will be included in v0.5.0 that's going to be released either Friday or on the upcoming weekend.

@jannfis
Copy link
Contributor

jannfis commented Sep 1, 2020

This should be fixed in v0.5.0 - you can now specify multiple equal images with different aliases, and they will be upgraded independently. Also, image alias is now logged.

Closing issue, feel free to re-open if you encounter problems.

@jannfis jannfis closed this as completed Sep 1, 2020
@hawksight
Copy link
Author

hawksight commented Sep 2, 2020

Hey @jannfis thanks for the update. I can certainly see that tag logging now which is very helpful.

I am still seeing issues, and I'm not sure if this might be a regression from v.0.4.0 beahviour.
Basically, The images I'm using have 2 or 3 tags, it would seem that the image updater keeps seeing the tags from the same image as newer than each other.

Here's the image(s) in the registry:
Screenshot from 2020-09-01 16-21-08

What I've seen overnight is the deployment continually being provided overrides to the new image tag.
eg. from v0.1.0-6e573a9c7455d88bf16c46638f299bbf3bf08b41 to cache to 6e573a9c7455d88bf16c46638f299bbf3bf08b41 and so on:
Screenshot from 2020-09-02 09-03-59

Overnight its nearly up to 600 revisions... I actually deleted the app yday whilst testing new 0.5.0 features, so it started from revision 1.

For reference my annotations are currently:

        argocd-image-updater.argoproj.io/image-list: asfalia=gcr.io/sopost-k8s/asfalia:~v0.1.0-0, celery=gcr.io/sopost-k8s/asfalia:~v0.1.0-0
        argocd-image-updater.argoproj.io/asfalia.update-strategy: latest
        argocd-image-updater.argoproj.io/asfalia.helm.image-name: image.repository
        argocd-image-updater.argoproj.io/asfalia.helm.image-tag: image.tag
        argocd-image-updater.argoproj.io/celery.update-strategy: latest
        argocd-image-updater.argoproj.io/celery.helm.image-name: celery.image.repository
        argocd-image-updater.argoproj.io/celery.helm.image-tag: celery.image.tag

So the issues I'm seeing is:

  1. Its cycling through the same docker image, with the varying tags associated.
  2. It doesn't seem to be respecting the semantic format tags only, I though it would discard the other tags.
  3. Does the image update update both images at once, so 1 deployment update, or will it set one container in a pod, then another (2 deployments?) - Sorry I can't tell, still have debug logs one, which I might turn off to see the logging improvements in info mode.

On point 2 above - I have tried:

argocd-image-updater.argoproj.io/asfalia.update-strategy: semver
argocd-image-updater.argoproj.io/celery.update-strategy: lsemver

With that strategy, it ignored the other tags cache and 6e573a9c7455d88bf16c46638f299bbf3bf08b41, however i found that it was updating to older versions as I assume after v0.1.0- its the evalutaing the githash alphabetically at that point.
So in that instance I found that image updater updated to the tag v0.1.0-fa5b97f04326847ffb0fc48f063ce089be18e7c4 which is actually 3 days older than the most recent image.
I am probably not using semver correctly here, I probably would need to move to something incremental in that scenario I think. Your advice very welcome though.

On 1 above - I think this might be a common use case to have multiple tags on an image. And certainly for me it's part of moving towards a world where we do version our image semantically, but until then I need to keep the original tagging format.

{edit} - In v0.4.0 of the image updater, i used the same annotations and did not have the issue of switching between tags on the same image. It would just say the other named were not in scope ( I think )

@jannfis jannfis reopened this Sep 2, 2020
@jannfis
Copy link
Contributor

jannfis commented Sep 2, 2020

Hi, thanks for the feedback!

I think I forgot to document that once you use an update strategy other than semver, the constraint on semantic version specified in the images to update is not taken into account anymore, because ultimately we support any tag for the other update strategies.

You can narrow down the list using a tag name matcher, with the annotation

argocd-image-updater.argoproj.io/<image_name>.tag-match: regexp:<regexp>

so in your case:

argocd-image-updater.argoproj.io/asfalia.tag-match: regexp:^v0.1.0-.*$
argocd-image-updater.argoproj.io/celery.tag-match: regexp:^v0.1.0-.*$

With above annotations, the image updater will only consider tags matching the regexp for finding the latest one. I think for v0.6.0, we'll also provide a more simple glob matcher func.

I'm not sure whether it was a smart move to drop the check on the semver constraint for simplified tag matching, or whether we should keep it.

Sorry for the circumstances.

@jannfis
Copy link
Contributor

jannfis commented Sep 2, 2020

FWIW, I have update the docs: https://argocd-image-updater.readthedocs.io/en/latest/configuration/images/#always-deploy-the-latest-build

@hawksight
Copy link
Author

hawksight commented Sep 2, 2020

Thanks for replying. I thought i might be using them wrong but I wasn't sure what the right combination was.

Ok so semver, needs to be semver.. its easier to program around because its a defined standard.
Using latest in combination with regex annotation allows me to craft something a but more bespoke when I'm not using a standard versioning system, but more limiting features because all bespoke standards can't be imagined and handled in one go.

I have just updated those on my test project and that's worked perfectly now. Thanks for the regex:

        argocd-image-updater.argoproj.io/image-list: asfalia=gcr.io/sopost-k8s/asfalia, celery=gcr.io/sopost-k8s/asfalia
        argocd-image-updater.argoproj.io/asfalia.update-strategy: latest
        argocd-image-updater.argoproj.io/asfalia.helm.image-name: image.repository
        argocd-image-updater.argoproj.io/asfalia.helm.image-tag: image.tag
        argocd-image-updater.argoproj.io/asfalia.tag-match: regexp:^v0.1.0-.*$
        argocd-image-updater.argoproj.io/celery.update-strategy: latest
        argocd-image-updater.argoproj.io/celery.helm.image-name: celery.image.repository
        argocd-image-updater.argoproj.io/celery.helm.image-tag: celery.image.tag
        argocd-image-updater.argoproj.io/celery.tag-match: regexp:^v0.1.0-.*$

I tried the regex in the docs but it did not seem to get any image results at all. Just so you know. I tried: regexp:^v0.1.0-[0-0a-zA-Z]+$ but found that the example you gave in this thread worked for me.

Thank you for fixing. I have one last comment about multiple image in an application.

Screenshot from 2020-09-02 15-10-30

I deleted and recreated app to to see how it upgraded from git. What happened (as you can see by 3 version)

  1. Deploy 1 - App deployed with versions from git as expected.
  2. Deploy 2 - Image updater updated the asfalia deployment the latest tag but not the celery container.
  3. Deploy 3 - Image updater updated celery to the latest allowed image matching asfalia container.

It'd be nice if it held off and performed the updates at once, or had the option to perhaps.
Maybe another annotation to consider?

argocd-image-updater.argoproj.io/images-update:< 'individual' | 'multiple' >
# or
argocd-image-updater.argoproj.io/update-method:< 'individual' | 'multiple' >

(maybe not he best names - but hope that gets the idea across, update all at once, or one at a time)

I might just need to test the scenario a few more times, but just feeding back what I'm seeing at the moment.

Btw I think we can close this issue as resolved now, thank you for the help 🌟.
I have another image I could possibly update (sql-proxy) in that deployment, so I'm going to give that a go now too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants