Skip to content

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

[#14844] fix(fileset): Return connection failures for named location checks (#14885)

mchadesaab6a66acec2
diff --git a/catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java b/catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java
index 9f9d16efe6..7da3a90b99 100644
--- a/catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java
+++ b/catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java
@@ -1202,8 +1202,15 @@ public class FilesetCatalogOperations extends ManagedSchemaOperations
+ locationName);
}
} catch (IOException e) {
- throw ExceptionMessages.wrap(
- "Failed to check if fileset catalog location exists: " + v, e);
+ // REST responses can include the cause chain. Keep backend diagnostics in the log.
+ LOG.warn(
+ "Failed to check {} for Fileset catalog {}.{}",
+ k,
+ catalogInfo.namespace(),
+ catalogInfo.name(),
+ e);
+ throw new ConnectionFailedException(
+ "Failed to check Fileset catalog storage at %s (%s)", k, failureCategory(e));
}
}
diff --git a/catalogs/catalog-fileset/src/test/java/org/apache/gravitino/catalog/fileset/TestFilesetCatalogOperations.java b/catalogs/catalog-fileset/src/test/java/org/apache/gravitino/catalog/fileset/TestFilesetCatalogOperations.java
index 0ab729bc75..dca9a991f4 100644
--- a/catalogs/catalog-fileset/src/test/java/org/apache/gravitino/catalog/fileset/TestFilesetCatalogOperations.java
+++ b/catalogs/catalog-fileset/src/test/java/org/apache/gravitino/catalog/fileset/TestFilesetCatalogOperations.java
@@ -2600,6 +2600,39 @@ public class TestFilesetCatalogOperations {
}
}
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testInitializeReportsNamedLocationAccessDenied(boolean failOnExists) throws IOException {
+ Path path = new Path("s3a://test-bucket/private-prefix");
+ FileSystem fileSystem = Mockito.mock(FileSystem.class);
+ AccessDeniedException denied =
+ new AccessDeniedException(path.toString(), null, "backend request ID");
+ if (failOnExists) {
+ when(fileSystem.exists(path)).thenThrow(denied);
+ } else {
+ when(fileSystem.exists(path)).thenReturn(true);
+ when(fileSystem.getFileStatus(path)).thenThrow(denied);
+ }
+
+ try (FilesetCatalogOperations ops =
+ Mockito.spy(new FilesetCatalogOperations(store, secretManager))) {
+ doReturn(fileSystem).when(ops).getFileSystem(Mockito.eq(path), Mockito.anyMap());
+ ConnectionFailedException failure =
+ Assertions.assertThrows(
+ ConnectionFailedException.class,
+ () ->
+ ops.initialize(
+ ImmutableMap.of(PROPERTY_MULTIPLE_LOCATIONS_PREFIX + "s3", path.toString()),
+ randomCatalogInfo("metalake", "catalog"),
+ FILESET_PROPERTIES_METADATA));
+
+ Assertions.assertEquals(
+ "Failed to check Fileset catalog storage at location-s3 (access denied)",
+ failure.getMessage());
+ Assertions.assertNull(failure.getCause());
+ }
+ }
+
@Test
public void testTestConnectionRejectsDefaultCatalogLocationThatIsAFile() throws IOException {
File fileLocation = new File(UNFORMALIZED_TEST_ROOT_PATH, "connection/default-file-location");