This is an automated email from the ASF dual-hosted git repository.
roryqi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 258b4c03b5 [#8219] feat(catalog): Throw exception when failed (#8222)
258b4c03b5 is described below
commit 258b4c03b574f859bc8ceaa370522c4f707d6aa2
Author: Daniel <[email protected]>
AuthorDate: Wed Aug 27 16:34:49 2025 +0800
[#8219] feat(catalog): Throw exception when failed (#8222)
### What changes were proposed in this pull request?
Updated the post hook behavior when catalog creation fails.
Now, if catalog creation encounters an error, the failure is correctly
propagated as an exception instead of returning success.
Fix: https://github.com/apache/gravitino/issues/8219
### Why are the changes needed?
Previously, when a catalog creation error occurred, the partially
created catalog was deleted, but the API still returned success.
This led to inconsistent and misleading results for users.
The fix ensures that the failure is explicitly reported, providing
accurate feedback.
Fix: https://github.com/apache/gravitino/issues/8219
### Does this PR introduce _any_ user-facing change?
No.
Users will only see more accurate error reporting when catalog creation
fails, without any change to existing success cases.
### How was this patch tested?
Built and tested locally.
---------
Co-authored-by: danielyyang <[email protected]>
Co-authored-by: Daniel <[email protected]>
---
.../ranger/integration/test/RangerHiveE2EIT.java | 32 ++++++++++++++++++++++
.../gravitino/hook/CatalogHookDispatcher.java | 1 +
2 files changed, 33 insertions(+)
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;