Skip to content

docker service rm for replicated-job service leaves orphaned task #44312

@mmenozzi

Description

@mmenozzi

Description

When removing a replicated-job service inside a stack with docker service rm, service is removed but the task is still listed with docker stack ps.

Reproduce

Put Docker in Swarm mode:

docker swarm init

Create a replicated-job service inside a new test_stack:

docker service create -l com.docker.stack.namespace=test_stack --name test_service --mode replicated-job php:8.1-fpm-alpine date

Verify that service is completed along its task:

➜ docker service ls
ID             NAME           MODE             REPLICAS              IMAGE                PORTS
7oznyuuqunrq   test_service   replicated job   0/1 (1/1 completed)   php:8.1-fpm-alpine

➜ docker stack ps test_stack
ID             NAME                                     IMAGE                NODE             DESIRED STATE   CURRENT STATE             ERROR     PORTS
3spgqd4kufbx   test_service.vt5bh0py0bucsq1mdafzg22hd   php:8.1-fpm-alpine   docker-desktop   Complete        Complete 54 seconds ago

Remove the test_service service:

docker service rm test_service

Verify that the service has been removed:

➜ docker service ls
ID        NAME      MODE      REPLICAS   IMAGE     PORTS

But the task is still listed and the only way to remove it is to leave the swarm:

➜ docker stack ps test_stack
ID             NAME                                                  IMAGE                NODE             DESIRED STATE   CURRENT STATE            ERROR     PORTS
3spgqd4kufbx   7oznyuuqunrqieagtuyzej151.vt5bh0py0bucsq1mdafzg22hd   php:8.1-fpm-alpine   docker-desktop   Complete        Complete 4 minutes ago

Expected behavior

docker stack ps test_stack should not list any task for the removed service or at least there should be a way to remove those "orphaned" tasks.

docker version

Client:
 Cloud integration: v1.0.29
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:04:45 2022
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.12.0 (85629)
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:01 2022
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.8
  GitCommit:        9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.9.1)
  compose: Docker Compose (Docker Inc., v2.10.2)
  extension: Manages Docker extensions (Docker Inc., v0.2.9)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.19.0)

Server:
 Containers: 26
  Running: 0
  Paused: 0
  Stopped: 26
 Images: 115
 Server Version: 20.10.17
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 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 logentries splunk syslog
 Swarm: active
  NodeID: vt5bh0py0bucsq1mdafzg22hd
  Is Manager: true
  ClusterID: a2xuru36gnlnayko2v8mqvxd3
  Managers: 1
  Nodes: 1
  Default Address Pool: 10.0.0.0/8
  SubnetSize: 24
  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 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.10.124-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 5
 Total Memory: 7.75GiB
 Name: docker-desktop
 ID: NB7Q:BIXT:7RC4:UYMH:5GFF:DPKN:RSTV:GGRF:MSTE:DXG4:J27U:CHBR
 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
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/swarmkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.version/20.10

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions