-
Notifications
You must be signed in to change notification settings - Fork 9.2k
YARN-6302 Fail the node, if Linux Container Executor is not configured properly #200
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
Changes from all commits
cb97a19
6f7872e
03f4cd8
c3e9721
8eb0fc1
d012be4
0aa9560
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.yarn.exceptions; | ||
|
|
||
| import org.apache.hadoop.classification.InterfaceAudience.Public; | ||
| import org.apache.hadoop.classification.InterfaceStability.Evolving; | ||
|
|
||
| /** | ||
| * This exception is thrown on unrecoverable configuration errors. | ||
| * An example is container launch error due to configuration. | ||
| */ | ||
| @Public | ||
| @Evolving | ||
| public class ConfigurationException extends YarnException { | ||
|
|
||
| private static final long serialVersionUID = 0x9801a7a0f8e3L; | ||
|
|
||
| public ConfigurationException(Throwable cause) { | ||
| super(cause); | ||
| } | ||
|
|
||
| public ConfigurationException(String message) { | ||
| super(message); | ||
| } | ||
|
|
||
| public ConfigurationException(String message, Throwable cause) { | ||
| super(message, cause); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ | |
| import org.apache.hadoop.yarn.api.ApplicationConstants; | ||
| import org.apache.hadoop.yarn.api.records.ContainerId; | ||
| import org.apache.hadoop.yarn.conf.YarnConfiguration; | ||
| import org.apache.hadoop.yarn.exceptions.ConfigurationException; | ||
| import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container; | ||
| import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerDiagnosticsUpdateEvent; | ||
| import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation; | ||
|
|
@@ -110,6 +111,58 @@ public class LinuxContainerExecutor extends ContainerExecutor { | |
| private ResourceHandler resourceHandlerChain; | ||
| private LinuxContainerRuntime linuxContainerRuntime; | ||
|
|
||
| /** | ||
| * The container exit code. | ||
| */ | ||
| public enum ExitCode { | ||
| SUCCESS(0), | ||
| INVALID_ARGUMENT_NUMBER(1), | ||
| INVALID_COMMAND_PROVIDED(3), | ||
| INVALID_NM_ROOT_DIRS(5), | ||
| SETUID_OPER_FAILED(6), | ||
| UNABLE_TO_EXECUTE_CONTAINER_SCRIPT(7), | ||
| UNABLE_TO_SIGNAL_CONTAINER(8), | ||
| INVALID_CONTAINER_PID(9), | ||
| OUT_OF_MEMORY(18), | ||
| INITIALIZE_USER_FAILED(20), | ||
| PATH_TO_DELETE_IS_NULL(21), | ||
| INVALID_CONTAINER_EXEC_PERMISSIONS(22), | ||
| INVALID_CONFIG_FILE(24), | ||
| SETSID_OPER_FAILED(25), | ||
| WRITE_PIDFILE_FAILED(26), | ||
| WRITE_CGROUP_FAILED(27), | ||
| TRAFFIC_CONTROL_EXECUTION_FAILED(28), | ||
| DOCKER_RUN_FAILED(29), | ||
| ERROR_OPENING_DOCKER_FILE(30), | ||
| ERROR_READING_DOCKER_FILE(31), | ||
| FEATURE_DISABLED(32), | ||
| COULD_NOT_CREATE_SCRIPT_COPY(33), | ||
| COULD_NOT_CREATE_CREDENTIALS_FILE(34), | ||
| COULD_NOT_CREATE_WORK_DIRECTORIES(35), | ||
| COULD_NOT_CREATE_APP_LOG_DIRECTORIES(36), | ||
| COULD_NOT_CREATE_TMP_DIRECTORIES(37), | ||
| ERROR_CREATE_CONTAINER_DIRECTORIES_ARGUMENTS(38); | ||
|
|
||
| private final int code; | ||
|
|
||
| ExitCode(int exitCode) { | ||
| this.code = exitCode; | ||
| } | ||
|
|
||
| /** | ||
| * Get the exit code as an int. | ||
| * @return the exit code as an int | ||
| */ | ||
| public int getExitCode() { | ||
| return code; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return String.valueOf(code); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Default constructor to allow for creation through reflection. | ||
| */ | ||
|
|
@@ -386,7 +439,8 @@ public void prepareContainer(ContainerPrepareContext ctx) throws IOException { | |
| } | ||
|
|
||
| @Override | ||
| public int launchContainer(ContainerStartContext ctx) throws IOException { | ||
| public int launchContainer(ContainerStartContext ctx) | ||
| throws IOException, ConfigurationException { | ||
| Container container = ctx.getContainer(); | ||
| Path nmPrivateContainerScriptPath = ctx.getNmPrivateContainerScriptPath(); | ||
| Path nmPrivateTokensPath = ctx.getNmPrivateTokensPath(); | ||
|
|
@@ -496,16 +550,16 @@ public int launchContainer(ContainerStartContext ctx) throws IOException { | |
| } else { | ||
| LOG.info( | ||
| "Container was marked as inactive. Returning terminated error"); | ||
| return ExitCode.TERMINATED.getExitCode(); | ||
| return ContainerExecutor.ExitCode.TERMINATED.getExitCode(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is needful, but you can do it if you want.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is one ExitCode now in this class as well.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, missed that. |
||
| } | ||
| } catch (ContainerExecutionException e) { | ||
| int exitCode = e.getExitCode(); | ||
| LOG.warn("Exit code from container " + containerId + " is : " + exitCode); | ||
| // 143 (SIGTERM) and 137 (SIGKILL) exit codes means the container was | ||
| // terminated/killed forcefully. In all other cases, log the | ||
| // output | ||
| if (exitCode != ExitCode.FORCE_KILLED.getExitCode() | ||
| && exitCode != ExitCode.TERMINATED.getExitCode()) { | ||
| if (exitCode != ContainerExecutor.ExitCode.FORCE_KILLED.getExitCode() | ||
| && exitCode != ContainerExecutor.ExitCode.TERMINATED.getExitCode()) { | ||
| LOG.warn("Exception from container-launch with container ID: " | ||
| + containerId + " and exit code: " + exitCode, e); | ||
|
|
||
|
|
@@ -525,6 +579,23 @@ public int launchContainer(ContainerStartContext ctx) throws IOException { | |
| logOutput(diagnostics); | ||
| container.handle(new ContainerDiagnosticsUpdateEvent(containerId, | ||
| diagnostics)); | ||
| if (exitCode == | ||
| ExitCode.INVALID_CONTAINER_EXEC_PERMISSIONS.getExitCode() || | ||
| exitCode == | ||
| ExitCode.INVALID_CONFIG_FILE.getExitCode() || | ||
| exitCode == | ||
| ExitCode.COULD_NOT_CREATE_SCRIPT_COPY.getExitCode() || | ||
| exitCode == | ||
| ExitCode.COULD_NOT_CREATE_CREDENTIALS_FILE.getExitCode() || | ||
| exitCode == | ||
| ExitCode.COULD_NOT_CREATE_WORK_DIRECTORIES.getExitCode() || | ||
| exitCode == | ||
| ExitCode.COULD_NOT_CREATE_APP_LOG_DIRECTORIES.getExitCode() || | ||
| exitCode == | ||
| ExitCode.COULD_NOT_CREATE_TMP_DIRECTORIES.getExitCode()) { | ||
| throw new ConfigurationException( | ||
| "Linux Container Executor reached unrecoverable exception", e); | ||
| } | ||
| } else { | ||
| container.handle(new ContainerDiagnosticsUpdateEvent(containerId, | ||
| "Container killed on request. Exit code is " + exitCode)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be @evolving?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right.