fmartinou / whats-up-docker

What's up Docker ( aka WUD ) gets you notified when a new version of your Docker Container is available.
https://fmartinou.github.io/whats-up-docker
MIT License
921 stars 29 forks source link

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

Open hivenet-mathieu-lacage opened 2 months ago

hivenet-mathieu-lacage commented 2 months ago

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.