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

Unable to detect changes in images that do not use semver #386

Open
hivenet-mathieu-lacage opened this issue May 7, 2024 · 0 comments
Open

Comments

@hivenet-mathieu-lacage
Copy link

I have a private registry where I have published images with non-semver tags (dev, preprod, prod tags). I configured the containers that reference these images with the following labels. Here is an exerpt from the ansible tasks that set this up:

- name: Install NAME
   community.docker.docker_container:
     name: NAME
     image: "{{docker_registry}}/NAME/NAME:dev"
     state: present
     restart_policy: unless-stopped
     labels: 
       wud.watch.digest: "true"

wud is configured via ansible too:

 - name: Install wud
   community.docker.docker_container:
     name: wud
     image: fmartinou/whats-up-docker
     state: present
     env:
       WUD_REGISTRY_CUSTOM_URL: https://REGISTRY.ovh.net
       WUD_REGISTRY_CUSTOM_LOGIN: "{{docker_read_username}}"
       WUD_REGISTRY_CUSTOM_PASSWORD: "{{docker_read_password}}"
       WUD_TRIGGER_DOCKER_DEFAULT_PRUNE: "true"
       WUD_LOG_LEVEL: DEBUG
     volumes:
        - /var/run/docker.sock:/var/run/docker.sock

Regardless of what tags I set in the registry, it appears wud does not detect that the tag has changed and does not update the corresponding container.

I got a bit curious so, as you can see, I enabled debug logging. I also added my own debugging statements in wud. The lack of any update appears to be caused by the else statement in https://github.com/fmartinou/whats-up-docker/blob/master/app/watchers/providers/docker/Docker.js#L516 that sets container.image.digest.value to an empty value (image.Config.Image is empty) which leads this to never be true.

So, I spent time reading: ./watchers/providers/docker/Docker.js:findNewVersion

Specifically, the else statement in https://github.com/fmartinou/whats-up-docker/blob/master/app/watchers/providers/docker/Docker.js#L516 fumbles me: you want to get the digest of the locally-running image so you look at the content of Config.Image but really neither the docker documentation nor my own experiments hint that there could be anything relevant in here.

Instead, I would have expected to see you access the RepoDigests field returned by inspect, split it at the @ character, and return the right-hand side. I am not very familiar with all the possible behaviors of docker and the semantics of Config.Image but this looks suspicious. I would be happy to put together a PR if you feel it makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant