YARN-6302 Fail the node, if Linux Container Executor is not configured properly - #200
miklosszegedi wants to merge 7 commits into
Conversation
Change-Id: Ia676061fd49cc7f54dbd9ae22bb999d4ea8a965b
Change-Id: Ib17d4a357b6fdf1a6d940f0641770054f1f73e81
Change-Id: Ib1e7215f9dac6825bda2eb54707782c59f19eb0c
| logOutput(diagnostics); | ||
| container.handle(new ContainerDiagnosticsUpdateEvent(containerId, | ||
| diagnostics)); | ||
| if (exitCode == LinuxContainerExecutorExitCode. |
There was a problem hiding this comment.
Would it be cleaner to create a new LinuxContainerExecutorExitCode from your exitCode and then test via ==?
There was a problem hiding this comment.
I get enum types cannot be instantiated. I could create a function that returns the appropriate enum for an int value, but would not that be an overkill here?
There was a problem hiding this comment.
Right. Forgot about that. You'd basically have to recreate the same code in the enum to get an instance from an int.
Maybe add an equals() method to the enum that can compare against ints as well? Maybe not worth it. Just shortening the enum name may be enough...
| import org.apache.hadoop.classification.InterfaceStability.Unstable; | ||
|
|
||
| /** | ||
| * This exception is thrown on unrecoverable container launch errors. |
There was a problem hiding this comment.
No reason to constrain the use of the exception. Maybe offer the launch errors as an example or suggested use?
There was a problem hiding this comment.
Agreed. Fixed the code.
|
|
||
| /** | ||
| * The container exit code. | ||
| */ |
| private NodeHealthScriptRunner nodeHealthScriptRunner; | ||
| private LocalDirsHandlerService dirsHandler; | ||
| private Exception nodeHealthException; | ||
| long nodeHealthExceptionReportTime; |
There was a problem hiding this comment.
My rule of thumb is that If it's not private, it should have javadocs.
There was a problem hiding this comment.
My mistake. Fixed.
| boolean scriptHealthStatus = (nodeHealthScriptRunner == null) ? true | ||
| : nodeHealthScriptRunner.isHealthy(); | ||
| return scriptHealthStatus && dirsHandler.areDisksHealthy(); | ||
| boolean scriptHealthStatus = nodeHealthScriptRunner == null || |
There was a problem hiding this comment.
Maybe rename this one scriptHealthy
| @@ -80,6 +97,7 @@ long getLastHealthReportTime() { | |||
| long lastReportTime = (nodeHealthScriptRunner == null) | |||
There was a problem hiding this comment.
This isn't your code, but it's hideous. Wanna clean it up, too? :)
| .setContainerLocalDirs(containerLocalDirs) | ||
| .setContainerLogDirs(containerLogDirs).build()); | ||
| } catch (ConfigurationException e) { | ||
| LOG.error("Failed to launch container.", e); |
There was a problem hiding this comment.
Since you know it was a configuration error, you may as well say so in the error message.
There was a problem hiding this comment.
It will be redundant, since the exception type is usually visible, but I fixed it.
| .setContainerLogDirs(containerLogDirs) | ||
| .build()); | ||
| } catch (ConfigurationException e) { | ||
| LOG.error("Failed to relaunch container.", e); |
There was a problem hiding this comment.
Since you know it was a configuration error, you may as well say so in the error message.
There was a problem hiding this comment.
It will be redundant, since the exception type is usually visible, but I fixed it.
| INVALID_ARGUMENT_NUMBER = 1, | ||
| INVALID_USER_NAME, //2 | ||
| INVALID_COMMAND_PROVIDED, //3 | ||
| //INVALID_USER_NAME 2 |
There was a problem hiding this comment.
This section of code makes me want to weep.
There was a problem hiding this comment.
INVALID_USER_NAME was forgotten earlier, so I removed it, and I just followed the pattern that is in the code right now keeping the original value commented.
If we want to refactor this right now, I would generate large pseudorandom number do be able to check the difference and be able to search for the error code like a GUID in a search engine.
There was a problem hiding this comment.
Yeah, I didn't mean it was your fault. Salvaging this code isn't your problem. :)
| * @return the reporting string of health of the node | ||
| */ | ||
| String getHealthReport() { | ||
| String healthReport = ""; |
There was a problem hiding this comment.
This would be a bit cleaner with a Joiner:
String scriptReport = (nodeHealthScriptRunner == null) ? null : nodeHealthScriptRunner.getHealthReport();
String discReport = dirsHandler.getDisksHealthReport(false);
String exceptionReport = nodeHealthException == null ? null : nodeHealthException.getMessage();
String healthReport = Joiner.on(SEPARATOR).skipNulls().join(scriptReport, discReport.equals("") ? null : discReport, exceptionReport);
The discReport throws a monkey wrench in the works because it's returning "" instead of null. There's probably a more elegant solution that what I did above...
| * This exception is thrown on unrecoverable configuration errors. | ||
| * An example is container launch error due to configuration. | ||
| */ | ||
| @Public |
| INVALID_ARGUMENT_NUMBER = 1, | ||
| INVALID_USER_NAME, //2 | ||
| INVALID_COMMAND_PROVIDED, //3 | ||
| //INVALID_USER_NAME 2 |
There was a problem hiding this comment.
Yeah, I didn't mean it was your fault. Salvaging this code isn't your problem. :)
| * This exception is thrown on unrecoverable configuration errors. | ||
| * An example is container launch error due to configuration. | ||
| */ | ||
| @Public |
|
|
||
| /** | ||
| * The container exit code. | ||
| */ |
There was a problem hiding this comment.
Since this is an inner class of LCE, you can safely drop the LCE from the enum name, which will make the subsequent code less messy.
| logOutput(diagnostics); | ||
| container.handle(new ContainerDiagnosticsUpdateEvent(containerId, | ||
| diagnostics)); | ||
| if (exitCode == LinuxContainerExecutorExitCode. |
There was a problem hiding this comment.
Right. Forgot about that. You'd basically have to recreate the same code in the enum to get an instance from an int.
Maybe add an equals() method to the enum that can compare against ints as well? Maybe not worth it. Just shortening the enum name may be enough...
| container.handle(new ContainerDiagnosticsUpdateEvent(containerId, | ||
| diagnostics)); | ||
| if (exitCode == LinuxContainerExecutorExitCode. | ||
| if (exitCode == ExitCode. |
There was a problem hiding this comment.
Sorry to pick, but can we split these lines on the == instead of the . ?
There was a problem hiding this comment.
What am I missing? It doesn't look like anything changed...
There was a problem hiding this comment.
I did not run my last git push. It should be fixed now.
| LOG.info( | ||
| "Container was marked as inactive. Returning terminated error"); | ||
| return ExitCode.TERMINATED.getExitCode(); | ||
| return ContainerExecutor.ExitCode.TERMINATED.getExitCode(); |
There was a problem hiding this comment.
I don't think this is needful, but you can do it if you want.
There was a problem hiding this comment.
There is one ExitCode now in this class as well.
YARN-6302 Fail the node, if Linux Container Executor is not configured properly