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

[JENKINS-37769] Failing to stop containers cleanly, so at least stopping them quickly #65

Merged
merged 1 commit into from
Oct 5, 2016

Conversation

jglick
Copy link
Member

@jglick jglick commented Sep 13, 2016

JENKINS-37769

@reviewbybees

@@ -62,7 +62,7 @@ public void test_run() throws IOException, InterruptedException {
EnvVars launchEnv = newLaunchEnv();
String containerId =
dockerClient.run(launchEnv, "learn/tutorial", null, null, Collections.<String, String>emptyMap(), Collections.<String>emptyList(), new EnvVars(),
dockerClient.whoAmI(), "true");
dockerClient.whoAmI(), "cat");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was bogus as true was returning immediately, so the container was not even running.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would also depend on open stdin AFAIR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sleep infinity might be a better choice (discussion).

@ghost
Copy link

ghost commented Sep 13, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@jglick jglick closed this Sep 17, 2016
@jglick jglick reopened this Sep 17, 2016
@@ -136,7 +136,7 @@ public String run(@Nonnull EnvVars launchEnv, @Nonnull String image, @CheckForNu
* @param containerId The container ID.
*/
public void stop(@Nonnull EnvVars launchEnv, @Nonnull String containerId) throws IOException, InterruptedException {
LaunchResult result = launch(launchEnv, false, "stop", containerId);
LaunchResult result = launch(launchEnv, false, "stop", "--time=1", containerId);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using kill this will stop the container immediately instead of waiting a second and killing it then.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So would --time=0. That is what I do not want to do. The intent is to allow the container to shut down gracefully.

The call to rm below ensures that it is stopped and removed, whatever else happens.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the current implementation will always run into the timeout (cat won't terminate). So as long as the containers are not able to stop gracefully it's one second which could be saved.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes…for now, until I can dig into the root problem, I would rather waste the second in the interest of offering a clean shutdown.

@stephenc
Copy link
Member

stephenc commented Oct 5, 2016

🐝 AIUI

@stephenc
Copy link
Member

stephenc commented Oct 5, 2016

@reviewbybees done

@ghost
Copy link

ghost commented Oct 5, 2016

This pull request has completed our internal processes and we now respectfully request the maintainers of this repository to consider our proposal contained within this pull request for merging.

@jglick jglick merged commit 5b09129 into jenkinsci:master Oct 5, 2016
@jglick jglick deleted the stop-JENKINS-37769 branch October 5, 2016 14:30
@ykoehler
Copy link

ykoehler commented Apr 5, 2017

10 seconds is too short for real scenario... Keep hitting this.

@cristim
Copy link

cristim commented Sep 13, 2017

We noticed that this times out commands executed in the container, unless they return in less than a second, which makes this plugin pretty much useless in the current state:

def img = docker.image('foo/bar:latest')
img.inside('-u root') {
 sh """
echo foo  # this works, as well as anything returning in less than 1second
sleep 10 # this times out after a second and gets killed
"""
}

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

Successfully merging this pull request may close these issues.

7 participants