Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#8219] feat(catalog): Throw exception when failed (#8222)

Daniel258b4c03b574
diff --git a/authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerHiveE2EIT.java b/authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerHiveE2EIT.java
index 79e8252a24..fc1ad726cc 100644
--- a/authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerHiveE2EIT.java
+++ b/authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerHiveE2EIT.java
@@ -238,6 +238,38 @@ public class RangerHiveE2EIT extends RangerBaseE2EIT {
throw new RuntimeException(e);
}
+ Map<String, String> rollbackFailProperties =
+ 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,
+ "invalid_password",
+ RangerAuthorizationProperties.RANGER_SERVICE_NAME,
+ "test_rollback_fail",
+ RangerAuthorizationProperties.RANGER_SERVICE_CREATE_IF_ABSENT,
+ "true");
+ Assertions.assertThrows(
+ RuntimeException.class,
+ () ->
+ metalake.createCatalog(
+ "testRollbackFail",
+ Catalog.Type.RELATIONAL,
+ provider,
+ "comment",
+ rollbackFailProperties));
+
// 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 =
diff --git a/core/src/main/java/org/apache/gravitino/hook/CatalogHookDispatcher.java b/core/src/main/java/org/apache/gravitino/hook/CatalogHookDispatcher.java
index 1f325b7c5c..8284765b0a 100644
--- a/core/src/main/java/org/apache/gravitino/hook/CatalogHookDispatcher.java
+++ b/core/src/main/java/org/apache/gravitino/hook/CatalogHookDispatcher.java
@@ -105,6 +105,7 @@ public class CatalogHookDispatcher implements CatalogDispatcher {
} catch (Exception e) {
LOG.warn("Fail to execute the post hook operations, rollback the catalog " + ident, e);
dispatcher.dropCatalog(ident, true);
+ throw e;
}
return catalog;