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

Add SKIP_FAILJOB_ON_STOP_ERROR flag #246

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public class DockerClient {
@Restricted(NoExternalUse.class)
public static boolean SKIP_RM_ON_STOP = Boolean.getBoolean(DockerClient.class.getName() + ".SKIP_RM_ON_STOP");

/**
* Skip failing a job if docker-stop / rm fails / times out.
*/
@SuppressFBWarnings(value="MS_SHOULD_BE_FINAL", justification="mutable for scripts")
@Restricted(NoExternalUse.class)
public static boolean SKIP_FAILJOB_ON_STOP_ERROR = Boolean.getBoolean(DockerClient.class.getName() + ".SKIP_FAILJOB_ON_STOP_ERROR");

// e.g. 2015-04-09T13:40:21.981801679Z
public static final String DOCKER_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";

Expand Down Expand Up @@ -181,7 +188,13 @@ public List<String> listProcess(@NonNull EnvVars launchEnv, @NonNull String cont
public void stop(@NonNull EnvVars launchEnv, @NonNull String containerId) throws IOException, InterruptedException {
LaunchResult result = launch(launchEnv, false, "stop", "--time=1", containerId);
if (result.getStatus() != 0) {
throw new IOException(String.format("Failed to kill container '%s'.", containerId));
if(SKIP_FAILJOB_ON_STOP_ERROR) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, "Failed to kill container {0}, SKIP_FAILJOB_ON_STOP_ERROR is enabled.", containerId);
}
} else {
throw new IOException(String.format("Failed to kill container '%s'.", containerId));
}
}
if (!SKIP_RM_ON_STOP) {
rm(launchEnv, containerId);
Expand All @@ -198,7 +211,13 @@ public void rm(@NonNull EnvVars launchEnv, @NonNull String containerId) throws I
LaunchResult result;
result = launch(launchEnv, false, "rm", "-f", containerId);
if (result.getStatus() != 0) {
throw new IOException(String.format("Failed to rm container '%s'.", containerId));
if(SKIP_FAILJOB_ON_STOP_ERROR) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, "Failed to rm container {0}, SKIP_FAILJOB_ON_STOP_ERROR is enabled.", containerId);
}
} else {
throw new IOException(String.format("Failed to rm container '%s'.", containerId));
}
}
}

Expand Down