Skip to content

Commit

Permalink
Propagate access control exception from metastore
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Sep 26, 2019
1 parent 445b7a5 commit 22cfc91
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1394,12 +1394,12 @@ private final <T> T alternativeCall(
chosenAlternative.updateAndGet(currentChosen -> Math.min(currentChosen, position));
return result;
}
catch (NoSuchObjectException e) {
// This is likely a valid response. We are not settling on an alternative yet.
// We will do it later when we get a more obviously valid response.
throw e;
}
catch (TException | RuntimeException exception) {
if (isValidExceptionalResponse(exception)) {
// This is likely a valid response. We are not settling on an alternative yet.
// We will do it later when we get a more obviously valid response.
throw exception;
}
if (firstException == null) {
firstException = exception;
}
Expand All @@ -1414,6 +1414,22 @@ else if (firstException != exception) {
throw propagate(firstException);
}

// TODO instead of whitelisting exceptions we propagate we should recognize exceptions which we suppress and try different alternative call
// this requires product tests with HDP 3
private static boolean isValidExceptionalResponse(Exception exception)
{
if (exception instanceof NoSuchObjectException) {
return true;
}

if (exception.toString().contains("AccessControlException")) {
// e.g. org.apache.hadoop.hive.metastore.api.MetaException: org.apache.hadoop.security.AccessControlException: Permission denied: ...
return true;
}

return false;
}

private ThriftMetastoreClient createMetastoreClient()
throws TException
{
Expand Down

0 comments on commit 22cfc91

Please sign in to comment.