New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YARN-3678 #20

Open
wants to merge 3 commits into
base: trunk
from
Jump to file or symbol
Failed to load files and symbols.
+27 −1
Diff settings

Always

Just for now

@@ -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;
@@ -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) {
@@ -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;
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.