Open
Description
Support guidelines
- I've read the support guidelines
I've found a bug and checked that ...
- ... the documentation does not mention anything about my problem
- ... there are no open or closed issues that are related to my problem
Description
Failed jobs should simply be stopped and not restart indefinitely.
Expected behaviour
When I deploy a new cron, it should not be triggered unless the period configuration says so.
A failed job should not be restarted automatically unless a specific configuration is set.
Actual behaviour
Failed jobs are restarted automatically when it fails on deploy.
Steps to reproduce
- Using the following compose file :
services:
cronjob:
image: 'crazymax/swarm-cronjob'
volumes:
- type: 'bind'
source: '/var/run/docker.sock'
target: '/var/run/docker.sock'
environment:
LOG_LEVEL: 'info'
LOG_JSON: 'false'
deploy:
mode: 'global'
placement:
constraints:
- 'node.role == manager'
some-cron:
image: 'hello-world'
command: ["/bin/sh", "plop"]
deploy:
replicas: 0
restart_policy:
condition: 'none'
max_attempts: 1
labels:
swarm.cronjob.enable: 'true'
swarm.cronjob.schedule: '23 00 * * *'
swarm.cronjob.skip-running: 'true'
swarm.cronjob.registry-auth: 'true'
swarm.cronjob.replicas: '1'
Because plop
does not exists, the job must fail.
- run
docker stack deploy -c ./compose.yaml test_cron
- It starts the job but it shouldn't
- Even though the job fails it is restarted
swarm-cronjob version
v1.13.0
Docker info
Client:
Version: 25.0.3
Context: desktop-linux
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1-desktop.4
Path: /Users/neirda/.docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.24.6-desktop.1
Path: /Users/neirda/.docker/cli-plugins/docker-compose
debug: Get a shell into any image or container. (Docker Inc.)
Version: 0.0.24
Path: /Users/neirda/.docker/cli-plugins/docker-debug
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.0
Path: /Users/neirda/.docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.22
Path: /Users/neirda/.docker/cli-plugins/docker-extension
feedback: Provide feedback, right in your terminal! (Docker Inc.)
Version: v1.0.4
Path: /Users/neirda/.docker/cli-plugins/docker-feedback
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.0.1
Path: /Users/neirda/.docker/cli-plugins/docker-init
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /Users/neirda/.docker/cli-plugins/docker-sbom
scout: Docker Scout (Docker Inc.)
Version: v1.5.0
Path: /Users/neirda/.docker/cli-plugins/docker-scout
Server:
Containers: 3
Running: 1
Paused: 0
Stopped: 2
Images: 3
Server Version: 25.0.3
Storage Driver: stargz
driver-type: io.containerd.snapshotter.v1
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: active
NodeID: t7uezlrr828t3fhnxh9sm2qnk
Is Manager: true
ClusterID: c50qlxvcbkccupyom3hk437w4
Managers: 1
Nodes: 1
Data Path Port: 4789
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 192.168.65.3
Manager Addresses:
192.168.65.3:2377
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
seccomp
Profile: unconfined
cgroupns
Kernel Version: 6.6.16-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: aarch64
CPUs: 10
Total Memory: 15.6GiB
Name: docker-desktop
ID: fba3f175-cf79-4e22-9bcd-234f978efa04
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5555
127.0.0.0/8
Live Restore Enabled: false
Docker Compose config
name: production
services:
cronjob:
deploy:
mode: global
placement:
constraints:
- node.role == manager
environment:
LOG_JSON: "false"
LOG_LEVEL: info
image: crazymax/swarm-cronjob
networks:
default: null
volumes:
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock
some-cron:
command:
- /bin/sh
- plop
deploy:
replicas: 0
labels:
swarm.cronjob.enable: "true"
swarm.cronjob.registry-auth: "true"
swarm.cronjob.replicas: "1"
swarm.cronjob.schedule: '23 00 * * *'
swarm.cronjob.skip-running: "true"
restart_policy:
condition: none
max_attempts: 1
image: hello-world
networks:
default: null
networks:
default:
name: production_default
Logs
test_cron_cronjob.0.5p38p8wgmst1@docker-desktop | Thu, 04 Apr 2024 16:00:40 UTC INF Starting swarm-cronjob v1.13.0
test_cron_cronjob.0.5p38p8wgmst1@docker-desktop | Thu, 04 Apr 2024 16:00:40 UTC DBG Creating Docker API client
test_cron_cronjob.0.5p38p8wgmst1@docker-desktop | Thu, 04 Apr 2024 16:00:40 UTC DBG 0 scheduled services found through labels
test_cron_cronjob.0.5p38p8wgmst1@docker-desktop | Thu, 04 Apr 2024 16:00:40 UTC DBG Starting the cron scheduler
test_cron_cronjob.0.5p38p8wgmst1@docker-desktop | Thu, 04 Apr 2024 16:00:40 UTC DBG Listening docker events...
test_cron_cronjob.0.5p38p8wgmst1@docker-desktop | Thu, 04 Apr 2024 16:00:40 UTC DBG Event triggered newstate= oldstate= service=test_cron_some-cron
test_cron_cronjob.0.5p38p8wgmst1@docker-desktop | Thu, 04 Apr 2024 16:00:40 UTC INF Add cronjob with schedule */2 * * * * service=test_cron_some-cron
test_cron_cronjob.0.5p38p8wgmst1@docker-desktop | Thu, 04 Apr 2024 16:00:40 UTC DBG Number of cronjob tasks: 1
Additional info
No response
Activity