Skip to content

YARN-6302 Fail the node, if Linux Container Executor is not configured properly - #200

Closed
miklosszegedi wants to merge 7 commits into
apache:trunkfrom
miklosszegedi:YARN-6302
Closed

miklosszegedi wants to merge 7 commits into
apache:trunkfrom
miklosszegedi:YARN-6302

Conversation

@miklosszegedi

Copy link
Copy Markdown
Contributor

YARN-6302 Fail the node, if Linux Container Executor is not configured properly

Miklos Szegedi added 3 commits March 7, 2017 14:39
Change-Id: Ia676061fd49cc7f54dbd9ae22bb999d4ea8a965b
Change-Id: Ib17d4a357b6fdf1a6d940f0641770054f1f73e81
Change-Id: Ib1e7215f9dac6825bda2eb54707782c59f19eb0c

@templedf templedf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch!

logOutput(diagnostics);
container.handle(new ContainerDiagnosticsUpdateEvent(containerId,
diagnostics));
if (exitCode == LinuxContainerExecutorExitCode.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be cleaner to create a new LinuxContainerExecutorExitCode from your exitCode and then test via ==?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to constrain the use of the exception. Maybe offer the launch errors as an example or suggested use?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Fixed the code.


/**
* The container exit code.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

private NodeHealthScriptRunner nodeHealthScriptRunner;
private LocalDirsHandlerService dirsHandler;
private Exception nodeHealthException;
long nodeHealthExceptionReportTime;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My rule of thumb is that If it's not private, it should have javadocs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake. Fixed.

boolean scriptHealthStatus = (nodeHealthScriptRunner == null) ? true
: nodeHealthScriptRunner.isHealthy();
return scriptHealthStatus && dirsHandler.areDisksHealthy();
boolean scriptHealthStatus = nodeHealthScriptRunner == null ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename this one scriptHealthy

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -80,6 +97,7 @@ long getLastHealthReportTime() {
long lastReportTime = (nodeHealthScriptRunner == null)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't your code, but it's hideous. Wanna clean it up, too? :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

.setContainerLocalDirs(containerLocalDirs)
.setContainerLogDirs(containerLogDirs).build());
} catch (ConfigurationException e) {
LOG.error("Failed to launch container.", e);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you know it was a configuration error, you may as well say so in the error message.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you know it was a configuration error, you may as well say so in the error message.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section of code makes me want to weep.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* This exception is thrown on unrecoverable configuration errors.
* An example is container launch error due to configuration.
*/
@Public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make it evolving?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right.

INVALID_ARGUMENT_NUMBER = 1,
INVALID_USER_NAME, //2
INVALID_COMMAND_PROVIDED, //3
//INVALID_USER_NAME 2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be @evolving?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right.


/**
* The container exit code.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

logOutput(diagnostics);
container.handle(new ContainerDiagnosticsUpdateEvent(containerId,
diagnostics));
if (exitCode == LinuxContainerExecutorExitCode.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to pick, but can we split these lines on the == instead of the . ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What am I missing? It doesn't look like anything changed...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needful, but you can do it if you want.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one ExitCode now in this class as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, missed that.

This was referenced Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants