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

Return Optional.empty() instead of rethrowing exception and catch RuntimeException when submiting #824

Merged
merged 5 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
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 @@ -145,7 +145,15 @@ private Optional<String> getYarnApplicationId(Application application) {
.map(ApplicationId::toString);
} catch (YarnException | IOException e) {
LOG.error("Failed to get app id for app: {}", application, e);
throw new IllegalStateException(e);
return Optional.empty();
} catch (RuntimeException e) {
// Yarn client sometimes throws IOException wrapped in RuntimeException
LOG.error("Failed to get app id for app: {}", application, e);
if (e.getCause() instanceof IOException) {
return Optional.empty();
}

throw e;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,29 @@ class YarnBackendTest extends Specification {
info.state == ApplicationState.BUSY
}

def "gets empty app info if IOException thrown"() {
given:
def app = newApplication(null)

when:
def info = backend.getInfo(app)

then:
1 * client.getApplications(*_) >> { throw new IOException() }
info.isEmpty()
}

def "gets empty app info if RuntimeException with IOException thrown"() {
given:
def app = newApplication(null)

when:
def info = backend.getInfo(app)

then:
1 * client.getApplications(*_) >> { throw new RuntimeException(new IOException("test")) }
info.isEmpty()
}

def "fetches logs"() {
given:
Expand Down Expand Up @@ -104,4 +127,5 @@ class YarnBackendTest extends Specification {
client.getApplications(*_) >> [yarnApp]
client.getApplicationReport(yarnId) >> yarnApp
}

}
Loading