Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

[Improvement] Always remove when requested #46

Open
rdehouss opened this issue Sep 2, 2020 · 1 comment
Open

[Improvement] Always remove when requested #46

rdehouss opened this issue Sep 2, 2020 · 1 comment

Comments

@rdehouss
Copy link

rdehouss commented Sep 2, 2020

Expected Behavior

When jaas terminates, for any reason (timeouts or the user cancels the task with CTRL-C for example), the service created should be removed so that, no "garbage" is left behing
If the flag --remove asks otherwise, don't remove the service

Current Behavior

When running a task, if the task timeouts or the user cancels the task with CTRL-C for example, the service will remaining and won't be removed

Possible Solution

From what I could understand in the code, the ServiceRemove function is only called when everything went "fine" (or at least, the service "finished" somehow):

	stopStates := []swarm.TaskState{
		swarm.TaskStateComplete,
		swarm.TaskStateFailed,
		swarm.TaskStateRejected,
	}

The solution could be that the ServiceRemove function is called when the jaas process "stops" (CTRL-C must be captured) or the task timeouts.

Steps to Reproduce (for bugs)

  1. docker -H "ssh://<manager>" run --rm -it -v /var/run/docker.sock:/var/run/docker.sock alexellis2/jaas run -r --image alexellis2/cows --timeout 1s
  2. docker service ls will give sth like:
ID                  NAME                                    MODE                REPLICAS            IMAGE                                                                      PORTS
z9y5v33nohdo        dreamy_sammet                           replicated          0/1                 alexellis2/cows:latest
  1. And docker service ps dreamy_sammet
ID                  NAME                IMAGE                    NODE                DESIRED STATE       CURRENT STATE             ERROR               PORTS
prcz9a29sd9z        dreamy_sammet.1     alexellis2/cows:latest   db-001              Shutdown            Complete 14 seconds ago
  1. You see the desired state so the service is still there :)

Context

Either a task can timeout for several reason or the user might cancel the request because of a mistake or even, there is a problem with the docker daemon that cause the service/task to be stuck in "Preparing" state.

All these reasons leaves "service zoombie" behinds

Your Environment

  • Version used: (latest from hub.docker.com)
  • Environment name and version (e.g. Docker 1.13): Docker version 19.03.12, build 48a66213fe
  • Server type and version: VM Linux 4.19.0-10-cloud-amd64 Implement service removal flag #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux
  • Operating System and version: Linux 4.19.0-10-cloud-amd64 Implement service removal flag #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux
  • Link to your project: N/A
@rdehouss
Copy link
Author

Another case where the service aren't eventually removed is when the container image does not exist or cannot be downloaded from the registry

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant