[ https://issues.apache.org/jira/browse/YARN-8508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16558571#comment-16558571 ]
Chandni Singh commented on YARN-8508: ------------------------------------- This happens with a container that gets cleaned up before its pid file is created. To solve it, we need to release the resources at the end of \{{LinuxContainerExecutor.reapContainer()}} just like we do in \{{LinuxContainerExecutor.launchContainer()}}, {\{LinuxContainerExecutor.reLaunchContainer()}}, and \{{LinuxContainerExecutor.reacquireContainer}}. Please see my explanation below: Refer \{{container_e21_1532545600682_0001_01_000002}} in yarn8505.nodemanager.log - 002 is launched but its pid file is not created {code} 2018-07-25 19:08:54,409 DEBUG util.ProcessIdFileReader (ProcessIdFileReader.java:getProcessId(53)) - Accessing pid from pid file /.../application_1532545600682_0001/container_e21_1532545600682_0001_01_000002/container_e21_1532545600682_0001_01_000002.pid 2018-07-25 19:08:54,409 DEBUG util.ProcessIdFileReader (ProcessIdFileReader.java:getProcessId(103)) - Got pid null from path /.../application_1532545600682_0001/container_e21_1532545600682_0001_01_000002/container_e21_1532545600682_0001_01_000002.pid {code} - Since application is killed, 002 is killed by ResourceManager {code} 2018-07-25 19:08:54,643 DEBUG container.ContainerImpl (ContainerImpl.java:handle(2080)) - Processing container_e21_1532545600682_0001_01_000002 of type CONTAINER_KILLED_ON_REQUEST {code} - The above triggers \{{ContainerLaunch.cleanupContainer()}} for 002. This happens before the pid file is created {code} 2018-07-25 19:08:54,409 WARN launcher.ContainerLaunch (ContainerLaunch.java:cleanupContainer(784)) - Container clean up before pid file created container_e21_1532545600682_0001_01_000002 {code} - \{{cleanupContainer}} invokes \{{reapDockerContainerNoPid(user)}} {code} 2018-07-25 19:08:54,410 INFO launcher.ContainerLaunch (ContainerLaunch.java:reapDockerContainerNoPid(940)) - Unable to obtain pid, but docker container request detected. Attempting to reap container container_e21_1532545600682_0001_01_000002 {code} - \{{reapDockerContainerNoPid(user)}} calls \{{exec.reapContainer(...)}} {code} 2018-07-25 19:08:54,412 DEBUG docker.DockerCommandExecutor (DockerCommandExecutor.java:executeDockerCommand(89)) - Running docker command: inspect docker-command=inspect format=\{{.State.Status}} name=container_e21_1532545600682_0001_01_000002 2018-07-25 19:08:54,412 DEBUG privileged.PrivilegedOperationExecutor (PrivilegedOperationExecutor.java:getPrivilegedOperationExecutionCommand(119)) - Privileged Execution Command Array: [/.../hadoop-yarn/bin/container-executor, --inspect-docker-container, --format=\{{.State.Status}}, container_e21_1532545600682_0001_01_000002] 2018-07-25 19:08:54,530 DEBUG docker.DockerCommandExecutor (DockerCommandExecutor.java:getContainerStatus(160)) - Container Status: nonexistent ContainerId: container_e21_1532545600682_0001_01_000002 2018-07-25 19:08:54,530 DEBUG launcher.ContainerLaunch (ContainerLaunch.java:reapDockerContainerNoPid(948)) - Sent signal to docker container container_e21_1532545600682_0001_01_000002 as user hrt_qa, result=success {code} - The problem is that the \{{reapContainer}} in \{{LinuxContainerExecutor}} doesn't release the resources assigned to the container. The below code snippet that performs these tasks after the container completes doesn't happen at this point. {code} resourcesHandler.postExecute(containerId); try { if (resourceHandlerChain != null) { LOG.info("{} POST Complete", containerId); resourceHandlerChain.postComplete(containerId); } } catch (ResourceHandlerException e) { LOG.warn("ResourceHandlerChain.postComplete failed for " + "containerId: " + containerId + ". Exception: " + e); } } {code} - The launch of container fails after 4 minutes and only then the resources are released. {code} 2018-07-25 19:12:09,999 WARN nodemanager.LinuxContainerExecutor (LinuxContainerExecutor.java:handleExitCode(593)) - Exit code from container container_e21_1532545600682_0001_01_000002 is : 27 2018-07-25 19:12:10,000 WARN nodemanager.LinuxContainerExecutor (LinuxContainerExecutor.java:handleExitCode(599)) - Exception from container-launch with container ID: container_e21_1532545600682_0001_01_000002 and exit code: 27 2018-07-25 19:12:10,000 INFO nodemanager.ContainerExecutor (ContainerExecutor.java:logOutput(541)) - Container id: container_e21_1532545600682_0001_01_000002 2018-07-25 19:12:10,003 INFO nodemanager.ContainerExecutor (ContainerExecutor.java:logOutput(541)) - Docker inspect command: /usr/bin/docker inspect --format \{{.State.Pid}} container_e21_1532545600682_0001_01_000002 2018-07-25 19:12:10,003 INFO nodemanager.ContainerExecutor (ContainerExecutor.java:logOutput(541)) - Failed to write pid to file /cgroup/cpu/.../container_e21_1532545600682_0001_01_000002/tasks - No such process 2018-07-25 19:12:10,003 INFO nodemanager.ContainerExecutor (ContainerExecutor.java:logOutput(541)) - Wrote the exit code 27 to /.../application_1532545600682_0001/container_e21_1532545600682_0001_01_000002/container_e21_1532545600682_0001_01_000002.pid.exitcode 2018-07-25 19:12:10,003 DEBUG container.ContainerImpl (ContainerImpl.java:handle(2080)) - Processing container_e21_1532545600682_0001_01_000002 of type UPDATE_DIAGNOSTICS_MSG 2018-07-25 19:12:10,004 DEBUG recovery.NMLeveldbStateStoreService (NMLeveldbStateStoreService.java:storeContainerDiagnostics(488)) - storeContainerDiagnostics: containerId=container_e21_1532545600682_0001_01_000002, diagnostics=[2018-07-25 19:08:49.283]Container Killed by ResourceManager Container id: container_e21_1532545600682_0001_01_000002 Docker inspect command: /usr/bin/docker inspect --format \{{.State.Pid}} container_e21_1532545600682_0001_01_000002 Failed to write pid to file /cgroup/cpu/.../container_e21_1532545600682_0001_01_000002/tasks - No such process {code} > GPU does not get released even though the container is killed > -------------------------------------------------------------- > > Key: YARN-8508 > URL: https://issues.apache.org/jira/browse/YARN-8508 > Project: Hadoop YARN > Issue Type: Bug > Reporter: Sumana Sathish > Assignee: Chandni Singh > Priority: Major > > GPU failed to release even though the container using it is being killed > {Code} > 2018-07-06 05:22:26,201 INFO container.ContainerImpl > (ContainerImpl.java:handle(2093)) - Container > container_e20_1530854311763_0006_01_000001 transitioned from RUNNING to > KILLING > 2018-07-06 05:22:26,250 INFO container.ContainerImpl > (ContainerImpl.java:handle(2093)) - Container > container_e20_1530854311763_0006_01_000002 transitioned from RUNNING to > KILLING > 2018-07-06 05:22:26,251 INFO application.ApplicationImpl > (ApplicationImpl.java:handle(632)) - Application > application_1530854311763_0006 transitioned from RUNNING to > FINISHING_CONTAINERS_WAIT > 2018-07-06 05:22:26,251 INFO launcher.ContainerLaunch > (ContainerLaunch.java:cleanupContainer(734)) - Cleaning up container > container_e20_1530854311763_0006_01_000002 > 2018-07-06 05:22:31,358 INFO launcher.ContainerLaunch > (ContainerLaunch.java:getContainerPid(1102)) - Could not get pid for > container_e20_1530854311763_0006_01_000002. Waited for 5000 ms. > 2018-07-06 05:22:31,358 WARN launcher.ContainerLaunch > (ContainerLaunch.java:cleanupContainer(784)) - Container clean up before pid > file created container_e20_1530854311763_0006_01_000002 > 2018-07-06 05:22:31,359 INFO launcher.ContainerLaunch > (ContainerLaunch.java:reapDockerContainerNoPid(940)) - Unable to obtain pid, > but docker container request detected. Attempting to reap container > container_e20_1530854311763_0006_01_000002 > 2018-07-06 05:22:31,494 INFO nodemanager.LinuxContainerExecutor > (LinuxContainerExecutor.java:deleteAsUser(828)) - Deleting absolute path : > /grid/0/hadoop/yarn/local/usercache/hrt_qa/appcache/application_1530854311763_0006/container_e20_1530854311763_0006_01_000002/launch_container.sh > 2018-07-06 05:22:31,500 INFO nodemanager.LinuxContainerExecutor > (LinuxContainerExecutor.java:deleteAsUser(828)) - Deleting absolute path : > /grid/0/hadoop/yarn/local/usercache/hrt_qa/appcache/application_1530854311763_0006/container_e20_1530854311763_0006_01_000002/container_tokens > 2018-07-06 05:22:31,510 INFO container.ContainerImpl > (ContainerImpl.java:handle(2093)) - Container > container_e20_1530854311763_0006_01_000001 transitioned from KILLING to > CONTAINER_CLEANEDUP_AFTER_KILL > 2018-07-06 05:22:31,510 INFO container.ContainerImpl > (ContainerImpl.java:handle(2093)) - Container > container_e20_1530854311763_0006_01_000002 transitioned from KILLING to > CONTAINER_CLEANEDUP_AFTER_KILL > 2018-07-06 05:22:31,512 INFO container.ContainerImpl > (ContainerImpl.java:handle(2093)) - Container > container_e20_1530854311763_0006_01_000001 transitioned from > CONTAINER_CLEANEDUP_AFTER_KILL to DONE > 2018-07-06 05:22:31,513 INFO container.ContainerImpl > (ContainerImpl.java:handle(2093)) - Container > container_e20_1530854311763_0006_01_000002 transitioned from > CONTAINER_CLEANEDUP_AFTER_KILL to DONE > 2018-07-06 05:22:38,955 INFO container.ContainerImpl > (ContainerImpl.java:handle(2093)) - Container > container_e20_1530854311763_0007_01_000002 transitioned from NEW to SCHEDULED > {Code} > New container requesting for GPU fails to launch > {code} > 2018-07-06 05:22:39,048 ERROR nodemanager.LinuxContainerExecutor > (LinuxContainerExecutor.java:handleLaunchForLaunchType(550)) - > ResourceHandlerChain.preStart() failed! > org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.ResourceHandlerException: > Failed to find enough GPUs, > requestor=container_e20_1530854311763_0007_01_000002, #RequestedGPUs=2, > #availableGpus=1 > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.gpu.GpuResourceAllocator.internalAssignGpus(GpuResourceAllocator.java:225) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.gpu.GpuResourceAllocator.assignGpus(GpuResourceAllocator.java:173) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.gpu.GpuResourceHandlerImpl.preStart(GpuResourceHandlerImpl.java:98) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.ResourceHandlerChain.preStart(ResourceHandlerChain.java:75) > at > org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor.handleLaunchForLaunchType(LinuxContainerExecutor.java:509) > at > org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor.launchContainer(LinuxContainerExecutor.java:479) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.launchContainer(ContainerLaunch.java:494) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:306) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:103) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) > at java.lang.Thread.run(Thread.java:748) > 2018-07-06 05:22:39,049 WARN launcher.ContainerLaunch > (ContainerLaunch.java:call(331)) - Failed to launch container. > java.io.IOException: ResourceHandlerChain.preStart() failed! > at > org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor.handleLaunchForLaunchType(LinuxContainerExecutor.java:551) > at > org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor.launchContainer(LinuxContainerExecutor.java:479) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.launchContainer(ContainerLaunch.java:494) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:306) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:103) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) > at java.lang.Thread.run(Thread.java:748) > Caused by: > org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.ResourceHandlerException: > Failed to find enough GPUs, > requestor=container_e20_1530854311763_0007_01_000002, #RequestedGPUs=2, > #availableGpus=1 > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.gpu.GpuResourceAllocator.internalAssignGpus(GpuResourceAllocator.java:225) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.gpu.GpuResourceAllocator.assignGpus(GpuResourceAllocator.java:173) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.gpu.GpuResourceHandlerImpl.preStart(GpuResourceHandlerImpl.java:98) > at > org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.ResourceHandlerChain.preStart(ResourceHandlerChain.java:75) > at > org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor.handleLaunchForLaunchType(LinuxContainerExecutor.java:509) > ... 8 more > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: yarn-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org