-
Notifications
You must be signed in to change notification settings - Fork 550
[#6716] improvement(authz): Delete catalogs if failing to execute post hook actions #6717
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
Changes from all commits
1e15f40
a8da330
c7dedb7
bd1d08b
325567a
a0fa85f
be9b066
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,10 +103,7 @@ protected RangerAuthorizationPlugin(String metalake, Map<String, String> config) | |
rangerServiceName = config.get(RangerAuthorizationProperties.RANGER_SERVICE_NAME); | ||
rangerClient = new RangerClientExtension(rangerUrl, authType, rangerAdminName, password); | ||
|
||
if (Boolean.parseBoolean( | ||
config.get(RangerAuthorizationProperties.RANGER_SERVICE_CREATE_IF_ABSENT))) { | ||
createRangerServiceIfNecessary(config, rangerServiceName); | ||
} | ||
createRangerServiceIfNecessary(config, rangerServiceName); | ||
|
||
rangerHelper = | ||
new RangerHelper( | ||
|
@@ -786,7 +783,9 @@ private void createRangerServiceIfNecessary(Map<String, String> config, String s | |
try { | ||
rangerClient.getService(serviceName); | ||
} catch (RangerServiceException rse) { | ||
if (rse.getStatus().equals(ClientResponse.Status.NOT_FOUND)) { | ||
if (Boolean.parseBoolean( | ||
config.get(RangerAuthorizationProperties.RANGER_SERVICE_CREATE_IF_ABSENT)) | ||
&& ClientResponse.Status.NOT_FOUND.equals(rse.getStatus())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have changed the original design: throw new AuthorizationPluginException(
"Fail to get ranger service name %s, exception: %s", serviceName, rse.getMessage()); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the change seems more reasonable for me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xunliu, could you please help confirm the original design? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it ok |
||
try { | ||
RangerService rangerService = new RangerService(); | ||
rangerService.setType(getServiceType()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,6 +237,45 @@ public void createCatalog() { | |
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
// Test to create a catalog with wrong properties which lacks Ranger service name, | ||
// It will throw RuntimeException with message that Ranger service name is required. | ||
Map<String, String> wrongProperties = | ||
ImmutableMap.of( | ||
HiveConstants.METASTORE_URIS, | ||
HIVE_METASTORE_URIS, | ||
IMPERSONATION_ENABLE, | ||
"true", | ||
AUTHORIZATION_PROVIDER, | ||
"ranger", | ||
RangerAuthorizationProperties.RANGER_SERVICE_TYPE, | ||
"HadoopSQL", | ||
RangerAuthorizationProperties.RANGER_ADMIN_URL, | ||
RangerITEnv.RANGER_ADMIN_URL, | ||
RangerAuthorizationProperties.RANGER_AUTH_TYPE, | ||
RangerContainer.authType, | ||
RangerAuthorizationProperties.RANGER_USERNAME, | ||
RangerContainer.rangerUserName, | ||
RangerAuthorizationProperties.RANGER_PASSWORD, | ||
RangerContainer.rangerPassword, | ||
RangerAuthorizationProperties.RANGER_SERVICE_CREATE_IF_ABSENT, | ||
"true"); | ||
Comment on lines
+243
to
+262
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which is the wrong properties? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remove the service name. This service name is required. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment in the here. Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
int catalogSize = metalake.listCatalogs().length; | ||
Exception exception = | ||
Assertions.assertThrows( | ||
RuntimeException.class, | ||
() -> | ||
metalake.createCatalog( | ||
"wrongTestProperties", | ||
Catalog.Type.RELATIONAL, | ||
provider, | ||
"comment", | ||
wrongProperties)); | ||
Assertions.assertTrue( | ||
exception.getMessage().contains("authorization.ranger.service.name is required")); | ||
|
||
Assertions.assertEquals(catalogSize, metalake.listCatalogs().length); | ||
} | ||
|
||
protected void checkTableAllPrivilegesExceptForCreating() { | ||
|
Uh oh!
There was an error while loading. Please reload this page.