YARN-8263. DockerClient still touches hadoop.tmp.dir. Contributed by Craig Condit
This commit is contained in:
parent
5033d7da8f
commit
7526815e32
@ -944,12 +944,12 @@ public void removeDockerContainer(String containerId) {
|
|||||||
PrivilegedOperationExecutor privOpExecutor =
|
PrivilegedOperationExecutor privOpExecutor =
|
||||||
PrivilegedOperationExecutor.getInstance(super.getConf());
|
PrivilegedOperationExecutor.getInstance(super.getConf());
|
||||||
if (DockerCommandExecutor.isRemovable(
|
if (DockerCommandExecutor.isRemovable(
|
||||||
DockerCommandExecutor.getContainerStatus(containerId,
|
DockerCommandExecutor.getContainerStatus(containerId, privOpExecutor,
|
||||||
super.getConf(), privOpExecutor, nmContext))) {
|
nmContext))) {
|
||||||
LOG.info("Removing Docker container : " + containerId);
|
LOG.info("Removing Docker container : " + containerId);
|
||||||
DockerRmCommand dockerRmCommand = new DockerRmCommand(containerId);
|
DockerRmCommand dockerRmCommand = new DockerRmCommand(containerId);
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerRmCommand, containerId,
|
DockerCommandExecutor.executeDockerCommand(dockerRmCommand, containerId,
|
||||||
null, super.getConf(), privOpExecutor, false, nmContext);
|
null, privOpExecutor, false, nmContext);
|
||||||
}
|
}
|
||||||
} catch (ContainerExecutionException e) {
|
} catch (ContainerExecutionException e) {
|
||||||
LOG.warn("Unable to remove docker container: " + containerId);
|
LOG.warn("Unable to remove docker container: " + containerId);
|
||||||
|
@ -298,7 +298,7 @@ public void initialize(Configuration conf, Context nmContext)
|
|||||||
throws ContainerExecutionException {
|
throws ContainerExecutionException {
|
||||||
this.nmContext = nmContext;
|
this.nmContext = nmContext;
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
dockerClient = new DockerClient(conf);
|
dockerClient = new DockerClient();
|
||||||
allowedNetworks.clear();
|
allowedNetworks.clear();
|
||||||
defaultROMounts.clear();
|
defaultROMounts.clear();
|
||||||
defaultRWMounts.clear();
|
defaultRWMounts.clear();
|
||||||
@ -973,7 +973,7 @@ public void relaunchContainer(ContainerRuntimeContext ctx)
|
|||||||
String containerIdStr = containerId.toString();
|
String containerIdStr = containerId.toString();
|
||||||
// Check to see if the container already exists for relaunch
|
// Check to see if the container already exists for relaunch
|
||||||
DockerCommandExecutor.DockerContainerStatus containerStatus =
|
DockerCommandExecutor.DockerContainerStatus containerStatus =
|
||||||
DockerCommandExecutor.getContainerStatus(containerIdStr, conf,
|
DockerCommandExecutor.getContainerStatus(containerIdStr,
|
||||||
privilegedOperationExecutor, nmContext);
|
privilegedOperationExecutor, nmContext);
|
||||||
if (containerStatus != null &&
|
if (containerStatus != null &&
|
||||||
DockerCommandExecutor.isStartable(containerStatus)) {
|
DockerCommandExecutor.isStartable(containerStatus)) {
|
||||||
@ -1219,13 +1219,13 @@ private void executeLivelinessCheck(ContainerRuntimeContext ctx)
|
|||||||
private void handleContainerStop(String containerId, Map<String, String> env)
|
private void handleContainerStop(String containerId, Map<String, String> env)
|
||||||
throws ContainerExecutionException {
|
throws ContainerExecutionException {
|
||||||
DockerCommandExecutor.DockerContainerStatus containerStatus =
|
DockerCommandExecutor.DockerContainerStatus containerStatus =
|
||||||
DockerCommandExecutor.getContainerStatus(containerId, conf,
|
DockerCommandExecutor.getContainerStatus(containerId,
|
||||||
privilegedOperationExecutor, nmContext);
|
privilegedOperationExecutor, nmContext);
|
||||||
if (DockerCommandExecutor.isStoppable(containerStatus)) {
|
if (DockerCommandExecutor.isStoppable(containerStatus)) {
|
||||||
DockerStopCommand dockerStopCommand = new DockerStopCommand(
|
DockerStopCommand dockerStopCommand = new DockerStopCommand(
|
||||||
containerId).setGracePeriod(dockerStopGracePeriod);
|
containerId).setGracePeriod(dockerStopGracePeriod);
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerStopCommand, containerId,
|
DockerCommandExecutor.executeDockerCommand(dockerStopCommand, containerId,
|
||||||
env, conf, privilegedOperationExecutor, false, nmContext);
|
env, privilegedOperationExecutor, false, nmContext);
|
||||||
} else {
|
} else {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
@ -1247,14 +1247,13 @@ private void handleContainerKill(ContainerRuntimeContext ctx,
|
|||||||
if (isContainerRequestedAsPrivileged(container)) {
|
if (isContainerRequestedAsPrivileged(container)) {
|
||||||
String containerId = container.getContainerId().toString();
|
String containerId = container.getContainerId().toString();
|
||||||
DockerCommandExecutor.DockerContainerStatus containerStatus =
|
DockerCommandExecutor.DockerContainerStatus containerStatus =
|
||||||
DockerCommandExecutor.getContainerStatus(containerId, conf,
|
DockerCommandExecutor.getContainerStatus(containerId,
|
||||||
privilegedOperationExecutor, nmContext);
|
privilegedOperationExecutor, nmContext);
|
||||||
if (DockerCommandExecutor.isKillable(containerStatus)) {
|
if (DockerCommandExecutor.isKillable(containerStatus)) {
|
||||||
DockerKillCommand dockerKillCommand =
|
DockerKillCommand dockerKillCommand =
|
||||||
new DockerKillCommand(containerId).setSignal(signal.name());
|
new DockerKillCommand(containerId).setSignal(signal.name());
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerKillCommand,
|
DockerCommandExecutor.executeDockerCommand(dockerKillCommand,
|
||||||
containerId, env, conf, privilegedOperationExecutor, false,
|
containerId, env, privilegedOperationExecutor, false, nmContext);
|
||||||
nmContext);
|
|
||||||
} else {
|
} else {
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"Container status is {}, skipping kill - {}",
|
"Container status is {}, skipping kill - {}",
|
||||||
@ -1292,12 +1291,12 @@ private void handleContainerRemove(String containerId,
|
|||||||
+ containerId);
|
+ containerId);
|
||||||
} else {
|
} else {
|
||||||
DockerCommandExecutor.DockerContainerStatus containerStatus =
|
DockerCommandExecutor.DockerContainerStatus containerStatus =
|
||||||
DockerCommandExecutor.getContainerStatus(containerId, conf,
|
DockerCommandExecutor.getContainerStatus(containerId,
|
||||||
privilegedOperationExecutor, nmContext);
|
privilegedOperationExecutor, nmContext);
|
||||||
if (DockerCommandExecutor.isRemovable(containerStatus)) {
|
if (DockerCommandExecutor.isRemovable(containerStatus)) {
|
||||||
DockerRmCommand dockerRmCommand = new DockerRmCommand(containerId);
|
DockerRmCommand dockerRmCommand = new DockerRmCommand(containerId);
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerRmCommand, containerId,
|
DockerCommandExecutor.executeDockerCommand(dockerRmCommand, containerId,
|
||||||
env, conf, privilegedOperationExecutor, false, nmContext);
|
env, privilegedOperationExecutor, false, nmContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.util.StringUtils;
|
import org.apache.hadoop.util.StringUtils;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||||
@ -50,58 +49,6 @@ public final class DockerClient {
|
|||||||
private static final String TMP_FILE_PREFIX = "docker.";
|
private static final String TMP_FILE_PREFIX = "docker.";
|
||||||
private static final String TMP_FILE_SUFFIX = ".cmd";
|
private static final String TMP_FILE_SUFFIX = ".cmd";
|
||||||
private static final String TMP_ENV_FILE_SUFFIX = ".env";
|
private static final String TMP_ENV_FILE_SUFFIX = ".env";
|
||||||
private final String tmpDirPath;
|
|
||||||
|
|
||||||
public DockerClient(Configuration conf) throws ContainerExecutionException {
|
|
||||||
|
|
||||||
String tmpDirBase = conf.get("hadoop.tmp.dir");
|
|
||||||
if (tmpDirBase == null) {
|
|
||||||
throw new ContainerExecutionException("hadoop.tmp.dir not set!");
|
|
||||||
}
|
|
||||||
tmpDirPath = tmpDirBase + "/nm-docker-cmds";
|
|
||||||
|
|
||||||
File tmpDir = new File(tmpDirPath);
|
|
||||||
if (!(tmpDir.exists() || tmpDir.mkdirs())) {
|
|
||||||
LOG.warn("Unable to create directory: " + tmpDirPath);
|
|
||||||
throw new ContainerExecutionException("Unable to create directory: " +
|
|
||||||
tmpDirPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String writeCommandToTempFile(DockerCommand cmd, String filePrefix)
|
|
||||||
throws ContainerExecutionException {
|
|
||||||
try {
|
|
||||||
File dockerCommandFile = File.createTempFile(TMP_FILE_PREFIX + filePrefix,
|
|
||||||
TMP_FILE_SUFFIX, new
|
|
||||||
File(tmpDirPath));
|
|
||||||
try (
|
|
||||||
Writer writer = new OutputStreamWriter(
|
|
||||||
new FileOutputStream(dockerCommandFile), "UTF-8");
|
|
||||||
PrintWriter printWriter = new PrintWriter(writer);
|
|
||||||
) {
|
|
||||||
printWriter.println("[docker-command-execution]");
|
|
||||||
for (Map.Entry<String, List<String>> entry :
|
|
||||||
cmd.getDockerCommandWithArguments().entrySet()) {
|
|
||||||
if (entry.getKey().contains("=")) {
|
|
||||||
throw new ContainerExecutionException(
|
|
||||||
"'=' found in entry for docker command file, key = " + entry
|
|
||||||
.getKey() + "; value = " + entry.getValue());
|
|
||||||
}
|
|
||||||
if (entry.getValue().contains("\n")) {
|
|
||||||
throw new ContainerExecutionException(
|
|
||||||
"'\\n' found in entry for docker command file, key = " + entry
|
|
||||||
.getKey() + "; value = " + entry.getValue());
|
|
||||||
}
|
|
||||||
printWriter.println(" " + entry.getKey() + "=" + StringUtils
|
|
||||||
.join(",", entry.getValue()));
|
|
||||||
}
|
|
||||||
return dockerCommandFile.getAbsolutePath();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.warn("Unable to write docker command to temporary file!");
|
|
||||||
throw new ContainerExecutionException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String writeEnvFile(DockerRunCommand cmd, String filePrefix,
|
private String writeEnvFile(DockerRunCommand cmd, String filePrefix,
|
||||||
File cmdDir) throws IOException {
|
File cmdDir) throws IOException {
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
|
||||||
import org.apache.hadoop.util.StringUtils;
|
import org.apache.hadoop.util.StringUtils;
|
||||||
import org.apache.hadoop.yarn.api.records.ContainerId;
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
||||||
@ -117,16 +116,15 @@ public void setClientConfigDir(String clientConfigDir) {
|
|||||||
* @param dockerCommand Specific command to be run by docker.
|
* @param dockerCommand Specific command to be run by docker.
|
||||||
* @param containerName
|
* @param containerName
|
||||||
* @param env
|
* @param env
|
||||||
* @param conf
|
|
||||||
* @param nmContext
|
* @param nmContext
|
||||||
* @return Returns the PrivilegedOperation object to be used.
|
* @return Returns the PrivilegedOperation object to be used.
|
||||||
* @throws ContainerExecutionException
|
* @throws ContainerExecutionException
|
||||||
*/
|
*/
|
||||||
public PrivilegedOperation preparePrivilegedOperation(
|
public PrivilegedOperation preparePrivilegedOperation(
|
||||||
DockerCommand dockerCommand, String containerName, Map<String,
|
DockerCommand dockerCommand, String containerName, Map<String,
|
||||||
String> env, Configuration conf, Context nmContext)
|
String> env, Context nmContext)
|
||||||
throws ContainerExecutionException {
|
throws ContainerExecutionException {
|
||||||
DockerClient dockerClient = new DockerClient(conf);
|
DockerClient dockerClient = new DockerClient();
|
||||||
String commandFile =
|
String commandFile =
|
||||||
dockerClient.writeCommandToTempFile(dockerCommand,
|
dockerClient.writeCommandToTempFile(dockerCommand,
|
||||||
ContainerId.fromString(containerName),
|
ContainerId.fromString(containerName),
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.docker;
|
package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.docker;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException;
|
||||||
@ -68,19 +67,18 @@ private DockerCommandExecutor() {
|
|||||||
* @param dockerCommand the docker command to run.
|
* @param dockerCommand the docker command to run.
|
||||||
* @param containerId the id of the container.
|
* @param containerId the id of the container.
|
||||||
* @param env environment for the container.
|
* @param env environment for the container.
|
||||||
* @param conf the hadoop configuration.
|
|
||||||
* @param privilegedOperationExecutor the privileged operations executor.
|
* @param privilegedOperationExecutor the privileged operations executor.
|
||||||
* @param disableFailureLogging disable logging for known rc failures.
|
* @param disableFailureLogging disable logging for known rc failures.
|
||||||
* @return the output of the operation.
|
* @return the output of the operation.
|
||||||
* @throws ContainerExecutionException if the operation fails.
|
* @throws ContainerExecutionException if the operation fails.
|
||||||
*/
|
*/
|
||||||
public static String executeDockerCommand(DockerCommand dockerCommand,
|
public static String executeDockerCommand(DockerCommand dockerCommand,
|
||||||
String containerId, Map<String, String> env, Configuration conf,
|
String containerId, Map<String, String> env,
|
||||||
PrivilegedOperationExecutor privilegedOperationExecutor,
|
PrivilegedOperationExecutor privilegedOperationExecutor,
|
||||||
boolean disableFailureLogging, Context nmContext)
|
boolean disableFailureLogging, Context nmContext)
|
||||||
throws ContainerExecutionException {
|
throws ContainerExecutionException {
|
||||||
PrivilegedOperation dockerOp = dockerCommand.preparePrivilegedOperation(
|
PrivilegedOperation dockerOp = dockerCommand.preparePrivilegedOperation(
|
||||||
dockerCommand, containerId, env, conf, nmContext);
|
dockerCommand, containerId, env, nmContext);
|
||||||
|
|
||||||
if (disableFailureLogging) {
|
if (disableFailureLogging) {
|
||||||
dockerOp.disableFailureLogging();
|
dockerOp.disableFailureLogging();
|
||||||
@ -108,18 +106,16 @@ public static String executeDockerCommand(DockerCommand dockerCommand,
|
|||||||
* an exception and the nonexistent status is returned.
|
* an exception and the nonexistent status is returned.
|
||||||
*
|
*
|
||||||
* @param containerId the id of the container.
|
* @param containerId the id of the container.
|
||||||
* @param conf the hadoop configuration.
|
|
||||||
* @param privilegedOperationExecutor the privileged operations executor.
|
* @param privilegedOperationExecutor the privileged operations executor.
|
||||||
* @return a {@link DockerContainerStatus} representing the current status.
|
* @return a {@link DockerContainerStatus} representing the current status.
|
||||||
*/
|
*/
|
||||||
public static DockerContainerStatus getContainerStatus(String containerId,
|
public static DockerContainerStatus getContainerStatus(String containerId,
|
||||||
Configuration conf,
|
|
||||||
PrivilegedOperationExecutor privilegedOperationExecutor,
|
PrivilegedOperationExecutor privilegedOperationExecutor,
|
||||||
Context nmContext) {
|
Context nmContext) {
|
||||||
try {
|
try {
|
||||||
DockerContainerStatus dockerContainerStatus;
|
DockerContainerStatus dockerContainerStatus;
|
||||||
String currentContainerStatus =
|
String currentContainerStatus =
|
||||||
executeStatusCommand(containerId, conf,
|
executeStatusCommand(containerId,
|
||||||
privilegedOperationExecutor, nmContext);
|
privilegedOperationExecutor, nmContext);
|
||||||
if (currentContainerStatus == null) {
|
if (currentContainerStatus == null) {
|
||||||
dockerContainerStatus = DockerContainerStatus.UNKNOWN;
|
dockerContainerStatus = DockerContainerStatus.UNKNOWN;
|
||||||
@ -170,13 +166,11 @@ public static DockerContainerStatus getContainerStatus(String containerId,
|
|||||||
* status.
|
* status.
|
||||||
*
|
*
|
||||||
* @param containerId the id of the container.
|
* @param containerId the id of the container.
|
||||||
* @param conf the hadoop configuration.
|
|
||||||
* @param privilegedOperationExecutor the privileged operations executor.
|
* @param privilegedOperationExecutor the privileged operations executor.
|
||||||
* @return the current container status.
|
* @return the current container status.
|
||||||
* @throws ContainerExecutionException if the docker operation fails to run.
|
* @throws ContainerExecutionException if the docker operation fails to run.
|
||||||
*/
|
*/
|
||||||
private static String executeStatusCommand(String containerId,
|
private static String executeStatusCommand(String containerId,
|
||||||
Configuration conf,
|
|
||||||
PrivilegedOperationExecutor privilegedOperationExecutor,
|
PrivilegedOperationExecutor privilegedOperationExecutor,
|
||||||
Context nmContext)
|
Context nmContext)
|
||||||
throws ContainerExecutionException {
|
throws ContainerExecutionException {
|
||||||
@ -184,8 +178,7 @@ private static String executeStatusCommand(String containerId,
|
|||||||
new DockerInspectCommand(containerId).getContainerStatus();
|
new DockerInspectCommand(containerId).getContainerStatus();
|
||||||
try {
|
try {
|
||||||
return DockerCommandExecutor.executeDockerCommand(dockerInspectCommand,
|
return DockerCommandExecutor.executeDockerCommand(dockerInspectCommand,
|
||||||
containerId, null, conf, privilegedOperationExecutor, true,
|
containerId, null, privilegedOperationExecutor, true, nmContext);
|
||||||
nmContext);
|
|
||||||
} catch (ContainerExecutionException e) {
|
} catch (ContainerExecutionException e) {
|
||||||
throw new ContainerExecutionException(e);
|
throw new ContainerExecutionException(e);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.docker;
|
package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.docker;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation;
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ public DockerInspectCommand getIpAndHost() {
|
|||||||
@Override
|
@Override
|
||||||
public PrivilegedOperation preparePrivilegedOperation(
|
public PrivilegedOperation preparePrivilegedOperation(
|
||||||
DockerCommand dockerCommand, String containerName, Map<String,
|
DockerCommand dockerCommand, String containerName, Map<String,
|
||||||
String> env, Configuration conf, Context nmContext) {
|
String> env, Context nmContext) {
|
||||||
PrivilegedOperation dockerOp = new PrivilegedOperation(
|
PrivilegedOperation dockerOp = new PrivilegedOperation(
|
||||||
PrivilegedOperation.OperationType.INSPECT_DOCKER_CONTAINER);
|
PrivilegedOperation.OperationType.INSPECT_DOCKER_CONTAINER);
|
||||||
dockerOp.appendArgs(commandArguments, containerName);
|
dockerOp.appendArgs(commandArguments, containerName);
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.docker;
|
package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.docker;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation;
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ public DockerRmCommand(String containerName) {
|
|||||||
@Override
|
@Override
|
||||||
public PrivilegedOperation preparePrivilegedOperation(
|
public PrivilegedOperation preparePrivilegedOperation(
|
||||||
DockerCommand dockerCommand, String containerName, Map<String,
|
DockerCommand dockerCommand, String containerName, Map<String,
|
||||||
String> env, Configuration conf, Context nmContext) {
|
String> env, Context nmContext) {
|
||||||
PrivilegedOperation dockerOp = new PrivilegedOperation(
|
PrivilegedOperation dockerOp = new PrivilegedOperation(
|
||||||
PrivilegedOperation.OperationType.REMOVE_DOCKER_CONTAINER);
|
PrivilegedOperation.OperationType.REMOVE_DOCKER_CONTAINER);
|
||||||
dockerOp.appendArgs(containerName);
|
dockerOp.appendArgs(containerName);
|
||||||
|
@ -68,7 +68,7 @@ public void testWriteCommandToTempFile() throws Exception {
|
|||||||
doReturn(conf).when(mockContext).getConf();
|
doReturn(conf).when(mockContext).getConf();
|
||||||
doReturn(dirsHandler).when(mockContext).getLocalDirsHandler();
|
doReturn(dirsHandler).when(mockContext).getLocalDirsHandler();
|
||||||
|
|
||||||
DockerClient dockerClient = new DockerClient(conf);
|
DockerClient dockerClient = new DockerClient();
|
||||||
dirsHandler.init(conf);
|
dirsHandler.init(conf);
|
||||||
dirsHandler.start();
|
dirsHandler.start();
|
||||||
String tmpPath = dockerClient.writeCommandToTempFile(dockerCmd, cid,
|
String tmpPath = dockerClient.writeCommandToTempFile(dockerCmd, cid,
|
||||||
|
@ -138,7 +138,7 @@ public void testExecuteDockerCommand() throws Exception {
|
|||||||
DockerStopCommand dockerStopCommand =
|
DockerStopCommand dockerStopCommand =
|
||||||
new DockerStopCommand(MOCK_CONTAINER_ID);
|
new DockerStopCommand(MOCK_CONTAINER_ID);
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerStopCommand,
|
DockerCommandExecutor.executeDockerCommand(dockerStopCommand,
|
||||||
cId.toString(), env, configuration, mockExecutor, false, nmContext);
|
cId.toString(), env, mockExecutor, false, nmContext);
|
||||||
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
||||||
.capturePrivilegedOperations(mockExecutor, 1, true);
|
.capturePrivilegedOperations(mockExecutor, 1, true);
|
||||||
assertEquals(1, ops.size());
|
assertEquals(1, ops.size());
|
||||||
@ -150,7 +150,7 @@ public void testExecuteDockerCommand() throws Exception {
|
|||||||
public void testExecuteDockerRm() throws Exception {
|
public void testExecuteDockerRm() throws Exception {
|
||||||
DockerRmCommand dockerCommand = new DockerRmCommand(MOCK_CONTAINER_ID);
|
DockerRmCommand dockerCommand = new DockerRmCommand(MOCK_CONTAINER_ID);
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerCommand, MOCK_CONTAINER_ID,
|
DockerCommandExecutor.executeDockerCommand(dockerCommand, MOCK_CONTAINER_ID,
|
||||||
env, configuration, mockExecutor, false, nmContext);
|
env, mockExecutor, false, nmContext);
|
||||||
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
||||||
.capturePrivilegedOperations(mockExecutor, 1, true);
|
.capturePrivilegedOperations(mockExecutor, 1, true);
|
||||||
PrivilegedOperation privOp = ops.get(0);
|
PrivilegedOperation privOp = ops.get(0);
|
||||||
@ -167,7 +167,7 @@ public void testExecuteDockerRm() throws Exception {
|
|||||||
public void testExecuteDockerStop() throws Exception {
|
public void testExecuteDockerStop() throws Exception {
|
||||||
DockerStopCommand dockerCommand = new DockerStopCommand(MOCK_CONTAINER_ID);
|
DockerStopCommand dockerCommand = new DockerStopCommand(MOCK_CONTAINER_ID);
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerCommand, MOCK_CONTAINER_ID,
|
DockerCommandExecutor.executeDockerCommand(dockerCommand, MOCK_CONTAINER_ID,
|
||||||
env, configuration, mockExecutor, false, nmContext);
|
env, mockExecutor, false, nmContext);
|
||||||
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
||||||
.capturePrivilegedOperations(mockExecutor, 1, true);
|
.capturePrivilegedOperations(mockExecutor, 1, true);
|
||||||
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
||||||
@ -185,7 +185,7 @@ public void testExecuteDockerInspectStatus() throws Exception {
|
|||||||
DockerInspectCommand dockerCommand =
|
DockerInspectCommand dockerCommand =
|
||||||
new DockerInspectCommand(MOCK_CONTAINER_ID).getContainerStatus();
|
new DockerInspectCommand(MOCK_CONTAINER_ID).getContainerStatus();
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerCommand, MOCK_CONTAINER_ID,
|
DockerCommandExecutor.executeDockerCommand(dockerCommand, MOCK_CONTAINER_ID,
|
||||||
env, configuration, mockExecutor, false, nmContext);
|
env, mockExecutor, false, nmContext);
|
||||||
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
||||||
.capturePrivilegedOperations(mockExecutor, 1, true);
|
.capturePrivilegedOperations(mockExecutor, 1, true);
|
||||||
PrivilegedOperation privOp = ops.get(0);
|
PrivilegedOperation privOp = ops.get(0);
|
||||||
@ -204,7 +204,7 @@ public void testExecuteDockerPull() throws Exception {
|
|||||||
DockerPullCommand dockerCommand =
|
DockerPullCommand dockerCommand =
|
||||||
new DockerPullCommand(MOCK_IMAGE_NAME);
|
new DockerPullCommand(MOCK_IMAGE_NAME);
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerCommand, MOCK_CONTAINER_ID,
|
DockerCommandExecutor.executeDockerCommand(dockerCommand, MOCK_CONTAINER_ID,
|
||||||
env, configuration, mockExecutor, false, nmContext);
|
env, mockExecutor, false, nmContext);
|
||||||
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
||||||
.capturePrivilegedOperations(mockExecutor, 1, true);
|
.capturePrivilegedOperations(mockExecutor, 1, true);
|
||||||
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
||||||
@ -222,7 +222,7 @@ public void testExecuteDockerLoad() throws Exception {
|
|||||||
DockerLoadCommand dockerCommand =
|
DockerLoadCommand dockerCommand =
|
||||||
new DockerLoadCommand(MOCK_LOCAL_IMAGE_NAME);
|
new DockerLoadCommand(MOCK_LOCAL_IMAGE_NAME);
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerCommand, MOCK_CONTAINER_ID,
|
DockerCommandExecutor.executeDockerCommand(dockerCommand, MOCK_CONTAINER_ID,
|
||||||
env, configuration, mockExecutor, false, nmContext);
|
env, mockExecutor, false, nmContext);
|
||||||
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
||||||
.capturePrivilegedOperations(mockExecutor, 1, true);
|
.capturePrivilegedOperations(mockExecutor, 1, true);
|
||||||
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
||||||
@ -244,7 +244,7 @@ public void testGetContainerStatus() throws Exception {
|
|||||||
any(PrivilegedOperation.class), eq(null), any(), eq(true), eq(false)))
|
any(PrivilegedOperation.class), eq(null), any(), eq(true), eq(false)))
|
||||||
.thenReturn(status.getName());
|
.thenReturn(status.getName());
|
||||||
assertEquals(status, DockerCommandExecutor.getContainerStatus(
|
assertEquals(status, DockerCommandExecutor.getContainerStatus(
|
||||||
MOCK_CONTAINER_ID, configuration, mockExecutor, nmContext));
|
MOCK_CONTAINER_ID, mockExecutor, nmContext));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ public void testExecuteDockerKillSIGQUIT() throws Exception {
|
|||||||
new DockerKillCommand(MOCK_CONTAINER_ID)
|
new DockerKillCommand(MOCK_CONTAINER_ID)
|
||||||
.setSignal(ContainerExecutor.Signal.QUIT.name());
|
.setSignal(ContainerExecutor.Signal.QUIT.name());
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerKillCommand,
|
DockerCommandExecutor.executeDockerCommand(dockerKillCommand,
|
||||||
MOCK_CONTAINER_ID, env, configuration, mockExecutor, false, nmContext);
|
MOCK_CONTAINER_ID, env, mockExecutor, false, nmContext);
|
||||||
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
||||||
.capturePrivilegedOperations(mockExecutor, 1, true);
|
.capturePrivilegedOperations(mockExecutor, 1, true);
|
||||||
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
||||||
@ -275,7 +275,7 @@ public void testExecuteDockerKillSIGKILL() throws Exception {
|
|||||||
new DockerKillCommand(MOCK_CONTAINER_ID)
|
new DockerKillCommand(MOCK_CONTAINER_ID)
|
||||||
.setSignal(ContainerExecutor.Signal.KILL.name());
|
.setSignal(ContainerExecutor.Signal.KILL.name());
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerKillCommand,
|
DockerCommandExecutor.executeDockerCommand(dockerKillCommand,
|
||||||
MOCK_CONTAINER_ID, env, configuration, mockExecutor, false, nmContext);
|
MOCK_CONTAINER_ID, env, mockExecutor, false, nmContext);
|
||||||
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
||||||
.capturePrivilegedOperations(mockExecutor, 1, true);
|
.capturePrivilegedOperations(mockExecutor, 1, true);
|
||||||
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
||||||
@ -296,7 +296,7 @@ public void testExecuteDockerKillSIGTERM() throws Exception {
|
|||||||
new DockerKillCommand(MOCK_CONTAINER_ID)
|
new DockerKillCommand(MOCK_CONTAINER_ID)
|
||||||
.setSignal(ContainerExecutor.Signal.TERM.name());
|
.setSignal(ContainerExecutor.Signal.TERM.name());
|
||||||
DockerCommandExecutor.executeDockerCommand(dockerKillCommand,
|
DockerCommandExecutor.executeDockerCommand(dockerKillCommand,
|
||||||
MOCK_CONTAINER_ID, env, configuration, mockExecutor, false, nmContext);
|
MOCK_CONTAINER_ID, env, mockExecutor, false, nmContext);
|
||||||
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
List<PrivilegedOperation> ops = MockPrivilegedOperationCaptor
|
||||||
.capturePrivilegedOperations(mockExecutor, 1, true);
|
.capturePrivilegedOperations(mockExecutor, 1, true);
|
||||||
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
List<String> dockerCommands = getValidatedDockerCommands(ops);
|
||||||
|
Loading…
Reference in New Issue
Block a user