YARN-5680. Add 2 new fields in Slider status output - image-name and is-privileged-container. Contributed by Billie Rinaldi

This commit is contained in:
Gour Saha 2016-10-25 20:00:27 -07:00 committed by Jian He
parent 773c565ac5
commit 1d7a42e795
3 changed files with 14 additions and 1 deletions

View File

@ -26,6 +26,7 @@ public interface DockerKeys {
String DOCKER_START_COMMAND = DOCKER_PREFIX + "startCommand";
String DEFAULT_DOCKER_NETWORK = "bridge";
Boolean DEFAULT_DOCKER_USE_PRIVILEGED = false;
String OUT_FILE = "stdout.txt";
String ERR_FILE = "stderr.txt";

View File

@ -131,7 +131,7 @@ public class DockerProviderService extends AbstractProviderService implements
launcher.setDockerNetwork(appConf.getComponentOpt(roleGroup, DOCKER_NETWORK,
DEFAULT_DOCKER_NETWORK));
launcher.setRunPrivilegedContainer(appConf.getComponentOptBool(roleGroup,
DOCKER_USE_PRIVILEGED, false));
DOCKER_USE_PRIVILEGED, DEFAULT_DOCKER_USE_PRIVILEGED));
// Set the environment
Map<String, String> standardTokens = providerUtils.getStandardTokenMap(

View File

@ -91,6 +91,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import static org.apache.slider.api.ResourceKeys.*;
import static org.apache.slider.api.RoleKeys.*;
import static org.apache.slider.api.StateValues.*;
import static org.apache.slider.providers.docker.DockerKeys.DEFAULT_DOCKER_USE_PRIVILEGED;
import static org.apache.slider.providers.docker.DockerKeys.DOCKER_IMAGE;
import static org.apache.slider.providers.docker.DockerKeys.DOCKER_USE_PRIVILEGED;
/**
* The model of all the ongoing state of a Slider AM.
@ -1823,6 +1826,15 @@ public class AppState {
if (SliderUtils.isSet(prefix)) {
cd.setRoleOpt(rolename, ROLE_PREFIX, SliderUtils.trimPrefix(prefix));
}
String dockerImage = instanceDefinition.getAppConfOperations()
.getComponentOpt(role.getGroup(), DOCKER_IMAGE, null);
if (SliderUtils.isSet(dockerImage)) {
cd.setRoleOpt(rolename, DOCKER_IMAGE, dockerImage);
Boolean dockerUsePrivileged = instanceDefinition.getAppConfOperations()
.getComponentOptBool(role.getGroup(), DOCKER_USE_PRIVILEGED,
DEFAULT_DOCKER_USE_PRIVILEGED);
cd.setRoleOpt(rolename, DOCKER_USE_PRIVILEGED, dockerUsePrivileged);
}
List<String> instances = instanceMap.get(rolename);
int nodeCount = instances != null ? instances.size(): 0;
cd.setRoleOpt(rolename, COMPONENT_INSTANCES,