[
https://issues.apache.org/jira/browse/YARN-7935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16387944#comment-16387944
]
Jason Lowe commented on YARN-7935:
----------------------------------
Why is this new environment variable only being set in the Docker case? The
application being launched may unconditionally be relying on this YARN
environment variable, and it won't be there in the non-Docker case. All of the
other YARN-provided environment variables are always set regardless of
container type, and I don't see why this should be an exception.
Catching NullPointerException is often a code smell, especially when the code
being wrapped by it is itself checking for nulls. I'd much rather this code
handle what it is expecting to potentially be null rather than catch NPE. This
smells like accommodating poor unit test mocking, and typically I'd much rather
see the mocks be updated than workarounds in the real code, especially if that
workaround is catching NPE.
{code:java}
private String getDockerNetworkType(Container container) {
String network;
try {
network = container.getLaunchContext().getEnvironment().get(
"YARN_CONTAINER_RUNTIME_DOCKER_CONTAINER_NETWORK");
if (network == null || network.isEmpty()) {
network = defaultNetwork;
}
} catch (NullPointerException e) {
network = defaultNetwork;
}
return network;
}
{code}
> Expose container's hostname to applications running within the docker
> container
> -------------------------------------------------------------------------------
>
> Key: YARN-7935
> URL: https://issues.apache.org/jira/browse/YARN-7935
> Project: Hadoop YARN
> Issue Type: Sub-task
> Components: yarn
> Reporter: Suma Shivaprasad
> Assignee: Suma Shivaprasad
> Priority: Major
> Attachments: YARN-7935.1.patch, YARN-7935.2.patch, YARN-7935.3.patch
>
>
> Some applications have a need to bind to the container's hostname (like
> Spark) which is different from the NodeManager's hostname(NM_HOST which is
> available as an env during container launch) when launched through Docker
> runtime. The container's hostname can be exposed to applications via an env
> CONTAINER_HOSTNAME. Another potential candidate is the container's IP but
> this can be addressed in a separate jira.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]