whats-up-docker icon indicating copy to clipboard operation
whats-up-docker copied to clipboard

Trigger not being invoked for docker-compose via cron

Open t-pohl opened this issue 2 years ago • 4 comments

Hey, I'm running WUD via docker-compose against docker-compose with one local watcher and multiple triggers for different compose files. Problem now is that containers are only auto updated if I restart WUD via docker-compose down and docker-compose up -d again but not if the watcher is invoked via cron. I see the invocation of the watcher in the WUD container logs as

wud              | 20:00:00.757  INFO whats-up-docker/watcher.docker.local: Cron started (0 * * * *)
wud              | 20:00:02.893  INFO whats-up-docker/watcher.docker.local: Cron finished (14 containers watched, 0 errors, 3 available updates)

but no update is triggered afterwards (2 of them should be ignored by threshold but 1 should run as it is only a patch upgrade). If I now just reboot WUD the patch upgrade will be performed.

Here my WUD configuration:

version: '3'
services:
  whatsupdocker:
    image: fmartinou/whats-up-docker:5.22.1
    container_name: wud
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      # wud needs all the docker-compose files which it should be able to update 
      # mounted as volumes
      # docker compose trigger can only upate in batch --> all containers in compose will be updated
      - $REPO_DIR/main-server/gitlab/docker-compose.yml:/docker-compose-files/gitlab-docker-compose.yml
      - $REPO_DIR/main-server/gitlab/gitlab-runner/docker-compose.yaml:/docker-compose-files/gitlab-runner-docker-compose.yml
      - $REPO_DIR/main-server/traefik/docker-compose.yml:/docker-compose-files/traefik-docker-compose.yml
      - $REPO_DIR/lizard/docker-compose.yml:/docker-compose-files/lizard-docker-compose.yml
      - $REPO_DIR/main-server/nextcloud/docker-compose.yml:/docker-compose-files/nextcloud-docker-compose.yml
    ports:
      - 3000:3000
    env_file:
      - .wud.env # just contains the password for the custom registry
    environment:
      # general wud configuration
      - "WUD_WATCHER_LOCAL_WATCHBYDEFAULT=true"
      - "WUD_WATCHER_LOCAL_CRON=0 * * * *"
      # registry configuration
      - "WUD_REGISTRY_CUSTOM_URL=..."
      - "WUD_REGISTRY_CUSTOM_LOGIN=gitlab-ci"
      # trigger definitons
      # trigger: GITLAB-UPDATE
      # where the mounted docker-compose file for the trigger resides inside the wud container
      - "WUD_TRIGGER_DOCKERCOMPOSE_GITLAB-UPDATE_FILE=/docker-compose-files/gitlab-docker-compose.yml"
      - "WUD_TRIGGER_DOCKERCOMPOSE_GITLAB-UPDATE_THRESHOLD=patch"
      - "WUD_TRIGGER_DOCKERCOMPOSE_GITLAB-UPDATE_PRUNE=true"
      # trigger: GITLAB-RUNNER-UPDATE
      - "WUD_TRIGGER_DOCKERCOMPOSE_GITLAB-RUNNER-UPDATE_FILE=/docker-compose-files/gitlab-runner-docker-compose.yml"
      - "WUD_TRIGGER_DOCKERCOMPOSE_GITLAB-RUNNER-UPDATE_THRESHOLD=patch"
      - "WUD_TRIGGER_DOCKERCOMPOSE_GITLAB-RUNNER-UPDATE_PRUNE=true"
      # trigger: TRAEFIK-UPDATE
      - "WUD_TRIGGER_DOCKERCOMPOSE_TRAEFIK-UPDATE_FILE=/docker-compose-files/traefik-docker-compose.yml"
      - "WUD_TRIGGER_DOCKERCOMPOSE_TRAEFIK-UPDATE_THRESHOLD=patch"
      - "WUD_TRIGGER_DOCKERCOMPOSE_TRAEFIK-UPDATE_PRUNE=true"
      - "WUD_TRIGGER_DOCKERCOMPOSE_TRAEFIK-UPDATE_ONCE=false"
      # trigger: LIZARD-UPDATE
      - "WUD_TRIGGER_DOCKERCOMPOSE_LIZARD-UPDATE_FILE=/docker-compose-files/lizard-docker-compose.yml"
      - "WUD_TRIGGER_DOCKERCOMPOSE_LIZARD-UPDATE_THRESHOLD=minor"
      - "WUD_TRIGGER_DOCKERCOMPOSE_LIZARD-UPDATE_PRUNE=true"
      # trigger: NEXTCLOUD-UPDATE
      - "WUD_TRIGGER_DOCKERCOMPOSE_NEXTCLOUD-UPDATE_FILE=/docker-compose-files/nextcloud-docker-compose.yml"
      - "WUD_TRIGGER_DOCKERCOMPOSE_NEXTCLOUD-UPDATE_THRESHOLD=minor"
      - "WUD_TRIGGER_DOCKERCOMPOSE_NEXTCLOUD-UPDATE_PRUNE=true"


Am I missing something here?

t-pohl avatar Dec 01 '22 21:12 t-pohl

Hi,

Are there any errors in the logs?

Can you please enable DEBUG logs then retry to see if something helpful is printed?

fmartinou avatar Dec 03 '22 19:12 fmartinou

Couldn't find any errors In the case I described the logs just end with

wud | 10:52:07.392 DEBUG whats-up-docker/trigger.dockercompose.traefik-update: Run trigger batch

which should then pull the container and update the image but does not. It's the last log.

I debugged a little more and it seems to me that it might be a permission problem on the volume which handles the compose file. If I mount it with permissions 664 I encountered the problem that changes to the compose file on the host (aka swaping the image file) which were made on the host were not reflected inside the container which seems like a problem for wud. Mounting it with 666 (so also +w for all) seems to solve this problem so the files are now in sync.

I do not know if this is really the cause for my problem but I'm going to run the container a little bit longer with these settings + DEBUG logs to see if it fixes the problem. If you have other ideas / want more logs feel free to reach out :D

t-pohl avatar Dec 04 '22 12:12 t-pohl

I also noticed that the files inside volume are owned by node. Could it be that the wud processes do not have the permissions to write these files because they run under a different user?

t-pohl avatar Dec 04 '22 13:12 t-pohl

@fmartinou I have the same problem. If I specify WUD_WATCHER_LOCAL_CRON, than no check for new versions is done. If I comment out this parameter, than everything is working

Arthedian avatar Mar 15 '24 18:03 Arthedian