diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/resources/definition/YARN-Simplified-V1-API-Layer-For-Services.yaml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/resources/definition/YARN-Simplified-V1-API-Layer-For-Services.yaml index 99767b3..aaf51b9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/resources/definition/YARN-Simplified-V1-API-Layer-For-Services.yaml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/resources/definition/YARN-Simplified-V1-API-Layer-For-Services.yaml @@ -247,6 +247,9 @@ definitions: kerberos_principal: description: The Kerberos Principal of the service $ref: '#/definitions/KerberosPrincipal' + docker_client_config: + type: string + description: The Docker client config for the service. ResourceInformation: description: ResourceInformation determines unit/value of resource types in addition to memory and vcores. It will be part of Resource object diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/TestApiServer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/TestApiServer.java index e473c3b..c13315e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/TestApiServer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/TestApiServer.java @@ -19,6 +19,9 @@ import static org.junit.Assert.*; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; import java.util.ArrayList; import java.util.List; @@ -27,6 +30,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.yarn.service.api.records.Artifact; import org.apache.hadoop.yarn.service.api.records.Artifact.TypeEnum; @@ -90,9 +94,22 @@ public void testBadCreateService() { } @Test - public void testGoodCreateService() { + public void testGoodCreateService() throws Exception { + String json = "{\"auths\": " + + "{\"https://index.docker.io/v1/\": " + + "{\"auth\": \"foobarbaz\"}," + + "\"registry.example.com\": " + + "{\"auth\": \"bazbarfoo\"}}}"; + File dockerTmpDir = new File("target", "docker-tmp"); + FileUtils.deleteQuietly(dockerTmpDir); + dockerTmpDir.mkdirs(); + String dockerConfig = dockerTmpDir + "/config.json"; + BufferedWriter bw = new BufferedWriter(new FileWriter(dockerConfig)); + bw.write(json); + bw.close(); Service service = new Service(); service.setName("jenkins"); + service.setDockerClientConfig(dockerConfig); Artifact artifact = new Artifact(); artifact.setType(TypeEnum.DOCKER); artifact.setId("jenkins:latest"); @@ -115,6 +132,32 @@ public void testGoodCreateService() { } @Test + public void testInternalServerErrorDockerClientConfigMissingCreateService() { + Service service = new Service(); + service.setName("jenkins"); + service.setDockerClientConfig("/does/not/exist/config.json"); + Artifact artifact = new Artifact(); + artifact.setType(TypeEnum.DOCKER); + artifact.setId("jenkins:latest"); + Resource resource = new Resource(); + resource.setCpus(1); + resource.setMemory("2048"); + List components = new ArrayList<>(); + Component c = new Component(); + c.setName("jenkins"); + c.setNumberOfContainers(1L); + c.setArtifact(artifact); + c.setLaunchCommand(""); + c.setResource(resource); + components.add(c); + service.setComponents(components); + final Response actual = apiServer.createService(request, service); + assertEquals("Create service is ", + Response.status(Status.INTERNAL_SERVER_ERROR).build().getStatus(), + actual.getStatus()); + } + + @Test public void testBadGetService() { final Response actual = apiServer.getService(request, "no-jenkins"); assertEquals("Get service is ", diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceMaster.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceMaster.java index 75cc9c5..5e7eabe 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceMaster.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceMaster.java @@ -18,6 +18,7 @@ package org.apache.hadoop.yarn.service; +import com.google.common.annotations.VisibleForTesting; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; import org.apache.commons.lang3.StringUtils; @@ -89,8 +90,8 @@ protected void serviceInit(Configuration conf) throws Exception { fs.setAppDir(appDir); loadApplicationJson(context, fs); + context.tokens = recordTokensForContainers(); if (UserGroupInformation.isSecurityEnabled()) { - context.tokens = recordTokensForContainers(); doSecureLogin(); } // Take yarn config from YarnFile and merge them into YarnConfiguration @@ -128,7 +129,8 @@ protected void serviceInit(Configuration conf) throws Exception { // Record the tokens and use them for launching containers. // e.g. localization requires the hdfs delegation tokens - private ByteBuffer recordTokensForContainers() throws IOException { + @VisibleForTesting + protected ByteBuffer recordTokensForContainers() throws IOException { Credentials copy = new Credentials(UserGroupInformation.getCurrentUser() .getCredentials()); DataOutputBuffer dob = new DataOutputBuffer(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/api/records/Service.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/api/records/Service.java index 392b71e..a5f5777 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/api/records/Service.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/api/records/Service.java @@ -74,6 +74,7 @@ @JsonProperty("kerberos_principal") @XmlElement(name = "kerberos_principal") private KerberosPrincipal kerberosPrincipal = new KerberosPrincipal(); + private String dockerClientConfig = null; /** * A unique service name. @@ -356,6 +357,27 @@ public void setKerberosPrincipal(KerberosPrincipal kerberosPrincipal) { this.kerberosPrincipal = kerberosPrincipal; } + @JsonProperty("docker_client_config") + @XmlElement(name = "docker_client_config") + @SuppressWarnings("checkstyle:hiddenfield") + public Service dockerClientConfig(String dockerClientConfig) { + this.dockerClientConfig = dockerClientConfig; + return this; + } + + /** + * The Docker client config for the service. + * @return dockerClientConfig + */ + @ApiModelProperty(value = "The Docker client config for the service") + public String getDockerClientConfig() { + return dockerClientConfig; + } + + public void setDockerClientConfig(String dockerClientConfig) { + this.dockerClientConfig = dockerClientConfig; + } + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -399,6 +421,8 @@ public String toString() { sb.append(" queue: ").append(toIndentedString(queue)).append("\n"); sb.append(" kerberosPrincipal: ") .append(toIndentedString(kerberosPrincipal)).append("\n"); + sb.append(" dockerClientConfig: ") + .append(toIndentedString(dockerClientConfig)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java index 5731e11..9543b7c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java @@ -76,6 +76,7 @@ import org.apache.hadoop.yarn.service.utils.SliderFileSystem; import org.apache.hadoop.yarn.service.utils.ServiceUtils; import org.apache.hadoop.yarn.service.utils.ZookeeperUtils; +import org.apache.hadoop.yarn.util.DockerClientConfigHandler; import org.apache.hadoop.yarn.util.Records; import org.apache.hadoop.yarn.util.Times; import org.slf4j.Logger; @@ -619,7 +620,7 @@ private ApplicationId submitApp(Service app) amLaunchContext.setCommands(Collections.singletonList(cmdStr)); amLaunchContext.setEnvironment(env); amLaunchContext.setLocalResources(localResources); - addHdfsDelegationTokenIfSecure(amLaunchContext); + addCredentials(amLaunchContext, app); submissionContext.setAMContainerSpec(amLaunchContext); yarnClient.submitApplication(submissionContext); return submissionContext.getApplicationId(); @@ -816,28 +817,44 @@ private Path persistAppDef(Path appDir, Service service) throws IOException { return appJson; } - private void addHdfsDelegationTokenIfSecure(ContainerLaunchContext amContext) + private void addCredentials(ContainerLaunchContext amContext, Service app) throws IOException { - if (!UserGroupInformation.isSecurityEnabled()) { - return; - } - Credentials credentials = new Credentials(); - String tokenRenewer = YarnClientUtils.getRmPrincipal(getConfig()); - if (StringUtils.isEmpty(tokenRenewer)) { - throw new IOException( - "Can't get Master Kerberos principal for the RM to use as renewer"); - } - // Get hdfs dt - final org.apache.hadoop.security.token.Token[] tokens = - fs.getFileSystem().addDelegationTokens(tokenRenewer, credentials); - if (tokens != null && tokens.length != 0) { - for (Token token : tokens) { - LOG.debug("Got DT: " + token); + // HDFS DT + Credentials hdfsCredentials = null; + if (UserGroupInformation.isSecurityEnabled()) { + hdfsCredentials = new Credentials(); + String tokenRenewer = YarnClientUtils.getRmPrincipal(getConfig()); + if (StringUtils.isEmpty(tokenRenewer)) { + throw new IOException( + "Can't get Master Kerberos principal for the RM to use as renewer"); + } + final org.apache.hadoop.security.token.Token[] tokens = + fs.getFileSystem().addDelegationTokens(tokenRenewer, hdfsCredentials); + if (tokens != null && tokens.length != 0) { + for (Token token : tokens) { + LOG.debug("Got DT: " + token); + } } + } + + Credentials dockerCredentials = null; + if (!StringUtils.isEmpty(app.getDockerClientConfig())) { + dockerCredentials = + DockerClientConfigHandler.readCredentialsFromConfigFile( + new Path(app.getDockerClientConfig()), + getConfig(), app.getName()); + } + + if (hdfsCredentials != null || dockerCredentials != null) { DataOutputBuffer dob = new DataOutputBuffer(); - credentials.writeTokenStorageToStream(dob); - ByteBuffer fsTokens = ByteBuffer.wrap(dob.getData(), 0, dob.getLength()); - amContext.setTokens(fsTokens); + if (hdfsCredentials != null) { + hdfsCredentials.writeTokenStorageToStream(dob); + } + if (dockerCredentials != null) { + dockerCredentials.writeTokenStorageToStream(dob); + } + ByteBuffer tokens = ByteBuffer.wrap(dob.getData(), 0, dob.getLength()); + amContext.setTokens(tokens); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ServiceApiUtil.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ServiceApiUtil.java index a5716bd..226225c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ServiceApiUtil.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ServiceApiUtil.java @@ -108,6 +108,21 @@ public static void validateAndResolveService(Service service, } } + // Validate the Docker client config. + if (!StringUtils.isEmpty(service.getDockerClientConfig())) { + URI dockerClientConfig; + try { + dockerClientConfig = new URI(service.getDockerClientConfig()); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } + if (!fs.getFileSystem().exists(new Path(dockerClientConfig))) { + throw new IOException( + "The supplied Docker client config does not exist: " + + dockerClientConfig); + } + } + // Validate there are no component name collisions (collisions are not // currently supported) and add any components from external services Configuration globalConf = service.getConfiguration(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/MockServiceAM.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/MockServiceAM.java index 4373893..2ca66fc 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/MockServiceAM.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/MockServiceAM.java @@ -21,11 +21,14 @@ import com.google.common.base.Supplier; import com.google.common.collect.Lists; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.DataOutputBuffer; import org.apache.hadoop.registry.client.api.RegistryOperations; import org.apache.hadoop.registry.client.binding.RegistryPathUtils; import org.apache.hadoop.registry.client.types.ServiceRecord; import org.apache.hadoop.registry.client.types.yarn.PersistencePolicies; import org.apache.hadoop.registry.client.types.yarn.YarnRegistryAttributes; +import org.apache.hadoop.security.Credentials; +import org.apache.hadoop.security.token.Token; import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse; @@ -46,6 +49,7 @@ import org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.proto.ClientAMProtocol; +import org.apache.hadoop.yarn.security.AMRMTokenIdentifier; import org.apache.hadoop.yarn.service.api.records.Service; import org.apache.hadoop.yarn.service.component.Component; import org.apache.hadoop.yarn.service.component.ComponentState; @@ -60,6 +64,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; +import java.nio.ByteBuffer; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; @@ -96,11 +101,19 @@ private Map containerStatuses = new ConcurrentHashMap<>(); + private Credentials amCreds; + public MockServiceAM(Service service) { super(service.getName()); this.service = service; } + public MockServiceAM(Service service, Credentials amCreds) { + super(service.getName()); + this.service = service; + this.amCreds = amCreds; + } + @Override protected ContainerId getAMContainerId() throws BadClusterStateException { @@ -385,4 +398,27 @@ private void addContainerStatus(Container container, ContainerState state) { containerStatuses.put(container.getId(), status); } + @Override + protected ByteBuffer recordTokensForContainers() + throws IOException { + DataOutputBuffer dob = new DataOutputBuffer(); + if (amCreds == null) { + return ByteBuffer.wrap(dob.getData(), 0, dob.getLength()); + } + try { + amCreds.writeTokenStorageToStream(dob); + } finally { + dob.close(); + } + // Now remove the AM->RM token so that task containers cannot access it. + Iterator> iter = amCreds.getAllTokens().iterator(); + while (iter.hasNext()) { + Token token = iter.next(); + LOG.info(token.toString()); + if (token.getKind().equals(AMRMTokenIdentifier.KIND_NAME)) { + iter.remove(); + } + } + return ByteBuffer.wrap(dob.getData(), 0, dob.getLength()); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestServiceAM.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestServiceAM.java index 8db98bd..57cf367 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestServiceAM.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestServiceAM.java @@ -21,6 +21,10 @@ import com.google.common.collect.ImmutableMap; import org.apache.commons.io.FileUtils; import org.apache.curator.test.TestingCluster; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.security.Credentials; +import org.apache.hadoop.security.token.Token; +import org.apache.hadoop.security.token.TokenIdentifier; import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.yarn.api.protocolrecords.ResourceTypes; import org.apache.hadoop.yarn.api.records.ApplicationId; @@ -29,6 +33,7 @@ import org.apache.hadoop.yarn.client.api.AMRMClient; import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; import org.apache.hadoop.yarn.conf.YarnConfiguration; +import org.apache.hadoop.yarn.security.DockerCredentialTokenIdentifier; import org.apache.hadoop.yarn.service.api.records.Component; import org.apache.hadoop.yarn.service.api.records.ResourceInformation; import org.apache.hadoop.yarn.service.api.records.Service; @@ -36,6 +41,7 @@ import org.apache.hadoop.yarn.service.component.instance.ComponentInstance; import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceState; import org.apache.hadoop.yarn.service.conf.YarnServiceConf; +import org.apache.hadoop.yarn.util.DockerClientConfigHandler; import org.apache.hadoop.yarn.util.resource.ResourceUtils; import org.junit.After; import org.junit.Assert; @@ -44,14 +50,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileWriter; import java.io.IOException; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.concurrent.TimeoutException; import static org.apache.hadoop.registry.client.api.RegistryConstants.KEY_REGISTRY_ZK_QUORUM; +import static org.junit.Assert.assertEquals; public class TestServiceAM extends ServiceTestUtils{ @@ -294,4 +304,44 @@ public void testScheduleWithMultipleResourceTypes() am.stop(); } + + @Test + public void testRecordTokensForContainers() throws Exception { + ApplicationId applicationId = ApplicationId.newInstance(123456, 1); + Service exampleApp = new Service(); + exampleApp.setId(applicationId.toString()); + exampleApp.setName("testContainerCompleted"); + exampleApp.addComponent(createComponent("compa", 1, "pwd")); + + String json = "{\"auths\": " + + "{\"https://index.docker.io/v1/\": " + + "{\"auth\": \"foobarbaz\"}," + + "\"registry.example.com\": " + + "{\"auth\": \"bazbarfoo\"}}}"; + File dockerTmpDir = new File("target", "docker-tmp"); + FileUtils.deleteQuietly(dockerTmpDir); + dockerTmpDir.mkdirs(); + String dockerConfig = dockerTmpDir + "/config.json"; + BufferedWriter bw = new BufferedWriter(new FileWriter(dockerConfig)); + bw.write(json); + bw.close(); + Credentials dockerCred = + DockerClientConfigHandler.readCredentialsFromConfigFile( + new Path(dockerConfig), conf, applicationId.toString()); + + + MockServiceAM am = new MockServiceAM(exampleApp, dockerCred); + ByteBuffer amCredBuffer = am.recordTokensForContainers(); + Credentials amCreds = + DockerClientConfigHandler.getCredentialsFromTokensByteBuffer( + amCredBuffer); + + assertEquals(2, amCreds.numberOfTokens()); + for (Token tk : amCreds.getAllTokens()) { + Assert.assertTrue( + tk.getKind().equals(DockerCredentialTokenIdentifier.KIND)); + } + + am.stop(); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java index 98bdbdd..76543a9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java @@ -160,9 +160,11 @@ public static void writeDockerCredentialsToPath(File outConfigFile, ObjectMapper mapper = new ObjectMapper(); ObjectNode rootNode = mapper.createObjectNode(); ObjectNode registryUrlNode = mapper.createObjectNode(); + boolean foundDockerCred = false; if (credentials.numberOfTokens() > 0) { for (Token tk : credentials.getAllTokens()) { if (tk.getKind().equals(DockerCredentialTokenIdentifier.KIND)) { + foundDockerCred = true; DockerCredentialTokenIdentifier ti = (DockerCredentialTokenIdentifier) tk.decodeIdentifier(); ObjectNode registryCredNode = mapper.createObjectNode(); @@ -175,9 +177,12 @@ public static void writeDockerCredentialsToPath(File outConfigFile, } } } - rootNode.put(CONFIG_AUTHS_KEY, registryUrlNode); - String json = - mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rootNode); - FileUtils.writeStringToFile(outConfigFile, json, Charset.defaultCharset()); + if (foundDockerCred) { + rootNode.put(CONFIG_AUTHS_KEY, registryUrlNode); + String json = + mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rootNode); + FileUtils.writeStringToFile( + outConfigFile, json, Charset.defaultCharset()); + } } } \ No newline at end of file diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/yarn-service/YarnServiceAPI.md b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/yarn-service/YarnServiceAPI.md index 6c38680..136582d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/yarn-service/YarnServiceAPI.md +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/yarn-service/YarnServiceAPI.md @@ -353,6 +353,7 @@ a service resource has the following attributes. |quicklinks|A blob of key-value pairs of quicklinks to be exported for a service.|false|object|| |queue|The YARN queue that this service should be submitted to.|false|string|| |kerberos_principal | The principal info of the user who launches the service|false|| +|docker_client_config | The Docker client config for the service|false|| ### ServiceState