Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerDiagnosticsUpdateEvent;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch;
import org.apache.hadoop.yarn.server.nodemanager.util.ProcessIdFileReader;
import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.util.Shell;
import org.apache.hadoop.util.StringUtils;

Expand Down Expand Up @@ -486,7 +487,11 @@ public DelayedProcessKiller(Container container, String user, String pid,
public void run() {
try {
Thread.sleep(delay);
containerExecutor.signalContainer(user, pid, signal);
ContainerId containerId = container.getContainerId();
String containerIdStr = ConverterUtils.toString(containerId);
if(null != containerIdStr && shouldDoSignal(containerIdStr, pid)){
containerExecutor.signalContainer(user, pid, signal);
}
} catch (InterruptedException e) {
return;
} catch (IOException e) {
Expand All @@ -497,5 +502,26 @@ public void run() {
.getContainerId(), message));
}
}

/**
* to check if the process is the container process
* @param containerIdStr
* @param processId
* @return
*/
private boolean shouldDoSignal(String containerIdStr, String processId)
{
try {
LOG.debug("here will do ps for " + containerIdStr);
String ret = Shell.execCommand("/bin/sh", "-c", "ps -ef | grep " + processId);
LOG.debug(ret);
boolean match = ret.contains(containerIdStr);
LOG.debug("match " + match);
return match;
} catch (IOException e) {
LOG.warn("not able to execute command /bin/sh -c 'ps'" );
}
return false;
}
}
}