Swarm: DIUN only alerts on existing version
Behaviour
DIUN is only alerting on the existing version even though the watch_repo label is added. Maybe my configuration is wrong.
Steps to reproduce this issue
- run docker stack deploy
- check diun logs
Expected behaviour
DIUN shows 5 most recent available tags.
Configuration
- Diun version : 4.22.0
- Platform (windows/linux) : Ubuntu 21.04
- System info: Linux 5.11.0-49-generic # 55-Ubuntu x86_64 x86_64 x86_64 GNU/Linux
.yml file
version: "3.5"
services:
influxdb:
image: influxdb:1.7
deploy:
replicas: 1
labels:
- diun.watch_repo=true
- diun.max_tags=5
diun:
image: crazymax/diun:latest
command: serve
volumes:
- "./data:/data"
- "/var/run/docker.sock:/var/run/docker.sock"
env_file:
- /my-path/diun.env
deploy:
mode: replicated
replicas: 1
restart_policy:
condition: any
.env
TZ=Europe/Berlin
LOG_LEVEL=info
LOG_JSON=true
DIUN_WATCH_WORKERS=20
DIUN_WATCH_SCHEDULE=*/5 * * * *
DIUN_PROVIDERS_SWARM=true
DIUN_PROVIDERS_SWARM_WATCHBYDEFAULT=true
DIUN_WATCH_FIRSTCHECKNOTIF=false
Logs
First time:
{"level":"info","provider":"swarm","image":"docker.io/library/influxdb:1.7","time":"2022-07-21T11:45:43+02:00","message":"New image found"}
{"level":"debug","provider":"swarm","image":"docker.io/library/influxdb:1.7","time":"2022-07-21T11:45:43+02:00","message":"Manifest saved to database"}
{"level":"debug","provider":"swarm","image":"docker.io/library/influxdb:1.7","time":"2022-07-21T11:45:43+02:00","message":"Skipping notification (first check)"}
Second run:
{"level":"debug","provider":"swarm","image":"docker.io/library/influxdb:1.7","time":"2022-07-21T11:50:03+02:00","message":"No changes"}
{"level":"debug","provider":"swarm","image":"docker.io/library/influxdb:1.7","time":"2022-07-21T11:50:03+02:00","message":"Manifest saved to database"}
{"level":"info","added":0,"updated":0,"unchanged":2,"skipped":0,"failed":0,"time":"2022-07-21T11:50:03+02:00","message":"Jobs completed"}
DIUN shows 5 most recent available tags.
Showing 5 more recent tags will depend on how the registry returns the list of tags. It depends on the provider.
As I can see you want to be notified about the influxdb image which is hosted on Docker Hub. AFAIK Docker Hub returns the list of tags in lexicographical order like:
[
"0.1.0",
"0.4.0",
"3.0.0-beta.1",
"3.0.0-beta.4",
"4",
"4.0.0",
"4.0.0-beta.1",
"4.1.0",
"4.1.1",
"4.10.0",
"4.11.0",
"4.20",
"4.20.0",
"4.20.1",
"4.3.0",
"4.3.1",
"4.9.0",
"edge",
"latest"
]
But Diun set diun.sort_tags to reverse by default when tags are fetched from the registry so the order will be:
[
"latest",
"edge",
"4.9.0",
"4.3.1",
"4.3.0",
"4.20.1",
"4.20.0",
"4.20",
"4.11.0",
"4.10.0",
"4.1.1",
"4.1.0",
"4.0.0-beta.1",
"4.0.0",
"4",
"3.0.0-beta.4",
"3.0.0-beta.1",
"0.4.0",
"0.1.0"
]
So in your case with diun.max_tags=5 and default option with diun.sort_tags=reverse it will check:
[
"latest",
"edge",
"4.9.0",
"4.3.1",
"4.3.0"
]
Possible values for diun.sort_tags are:
default: do not sort and use the expected tags list from the registryreverse: reverse order for the tags list from the registrylexicographical: sort the tags list lexicographicallysemver: sort the tags list using semantic versioning
More info: https://crazymax.dev/diun/faq/#tags-sorting-when-using-watch_repo
If you want the most recent semver tags (which is the most useful pattern imo) and looking at the influxdb image, I guess your best shot is to filter tags with diun.include_tags and set diun.sort_tags=semver:
services:
influxdb:
image: influxdb:1.7
deploy:
replicas: 1
labels:
- "diun.watch_repo=true"
- "diun.max_tags=5"
- "diun.sort_tags=semver"
- "diun.include_tags=^\\d+\\.\\d+\\.\\d+$"
If you want to sort by "most recent" tags this is unfortunately not possible as the metadata from registry API that returns the list of tags does not include the "last pushed date" :disappointed:.