Skip to content
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

[FLINK-5488] stop YarnClient before exception is thrown #4022

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ protected YarnClient getYarnClient() {
@Override
public YarnClusterClient retrieve(String applicationID) {

final YarnClient yarnClient = getYarnClient();
try {
// check if required Hadoop environment variables are set. If not, warn user
if (System.getenv("HADOOP_CONF_DIR") == null &&
Copy link
Contributor

Choose a reason for hiding this comment

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

does getYarnClient() fail if this condition is fulfilled? If so we should put this if block before the call to getYarnClient().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a good point, I will put getYarnClient() in the try block

Expand All @@ -402,7 +403,6 @@ public YarnClusterClient retrieve(String applicationID) {
}

final ApplicationId yarnAppId = ConverterUtils.toApplicationId(applicationID);
final YarnClient yarnClient = getYarnClient();
final ApplicationReport appReport = yarnClient.getApplicationReport(yarnAppId);

if (appReport.getFinalApplicationStatus() != FinalApplicationStatus.UNDEFINED) {
Expand All @@ -420,6 +420,7 @@ public YarnClusterClient retrieve(String applicationID) {

return createYarnClusterClient(this, yarnClient, appReport, flinkConfiguration, false);
} catch (Exception e) {
yarnClient.stop();
throw new RuntimeException("Couldn't retrieve Yarn cluster", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ public List<String> getNewMessages() {

@Override
public void finalizeCluster() {
// Do nothing
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert the changes here. This file is part of another big initiative (referred to as FLIP-6); we shouldn't touch it unless necessary. (basically, I don't know about the yarn-client life-cycle here so let's be conservative.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have reverted the changes and fixed another problem as Ted Yu metioned in FLINK-5488, thanks @zentol

LOG.info("YARN Client is shutting down");
yarnClient.stop();
yarnClient = null; // set null to clearly see if somebody wants to access it afterwards.
}

@Override
Expand Down