Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service Removal in Docker Client Library Ignoring Stop Grace Period in Docker Swarm #666

Closed
amrshadid opened this issue Dec 5, 2023 · 1 comment

Comments

@amrshadid
Copy link

amrshadid commented Dec 5, 2023

Description

The removeService method within the Spotify's docker-client functions as expected for service removal. However, it seems not to adhere to the stop-grace-period parameter, preventing the server from executing necessary cleanup steps before the service termination.

How to reproduce

  1. Start a Docker Swarm cluster with multiple nodes.
  2. Deploy a service using the docker service create command and set a stop-grace-period of 60 seconds for example.
  3. Execute the following code using the removeService method in the Docker Client library:
    private void removeDockerSwarmService(final String backendId, final DockerServer server)
            throws DockerServerException, NotFoundException {
        try {
            getDockerClient(server).removeService(backendId);
        } catch (ServiceNotFoundException e) {
            log.error(e.getMessage(), e);
            throw new NotFoundException(e);
        } catch (DockerException | InterruptedException e) {
            log.error(e.getMessage(), e);
            throw new DockerServerException(e);
        }
    }
    
  1. Observe that the service is immediately removed without waiting the 'stop-grace-period'.

Expected behavior

When utilizing removeDockerSwarmService to remove a service in Docker Swarm, it should honor the stop-grace-period parameter, allowing the server to complete essential cleanup operations before terminating the service.

Actual behavior

The service is immediately removed without honoring the stop-grace-period, potentially hindering the server from completing crucial cleanup tasks.

Software:

  • docker version: '24.0.5'
  • Spotify's docker-client version: '6.0.4'

Full backtrace

[Not applicable]
@dmandalidis
Copy link
Owner

Hi @amrshadid,

The responsibility of honoring the stop-grace-period is on the Docker swarm side. A docker client (whether is this or just a plain HTTP call) will return immediately after a docker service rm.

If you think it somehow differently, it would be a very bad API design from the Docker folks, if the client could actually affect this.

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

No branches or pull requests

2 participants