This is an automated email from the ASF dual-hosted git repository.
diqiu50 pushed a commit to branch cherry-pick-30a11bb0-to-branch-1.3
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to
refs/heads/cherry-pick-30a11bb0-to-branch-1.3 by this push:
new 12f3f77d88 Resolve cherry-pick conflicts for branch-1.3
12f3f77d88 is described below
commit 12f3f77d8881d810c7e94c6f83a37f6758d2fbb5
Author: diqiu50 <[email protected]>
AuthorDate: Tue Nov 3 21:25:41 2026 +0800
Resolve cherry-pick conflicts for branch-1.3
Adapt to exceptions and shared AWS property metadata that are not
available on branch-1.3.
---
.../glue/GlueCatalogPropertiesMetadata.java | 13 +--
.../catalog/glue/GlueExceptionConverter.java | 16 +--
.../catalog/glue/TestGlueCatalogCredentials.java | 125 ---------------------
.../glue/TestGlueCatalogPropertiesMetadata.java | 4 -
.../glue/TestGlueCatalogSchemaOperations.java | 7 +-
.../catalog/glue/TestGlueExceptionConverter.java | 18 ++-
.../server/web/rest/TestExceptionHandlers.java | 44 --------
7 files changed, 21 insertions(+), 206 deletions(-)
diff --git
a/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueCatalogPropertiesMetadata.java
b/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueCatalogPropertiesMetadata.java
index 7efa71acf8..2b05f0d64e 100644
---
a/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueCatalogPropertiesMetadata.java
+++
b/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueCatalogPropertiesMetadata.java
@@ -34,6 +34,7 @@ import static
org.apache.gravitino.catalog.glue.GlueConstants.DEFAULT_TABLE_FORM
import static
org.apache.gravitino.catalog.glue.GlueConstants.DEFAULT_TABLE_FORMAT_VALUE;
import static
org.apache.gravitino.catalog.glue.GlueConstants.TABLE_FORMAT_FILTER;
import static org.apache.gravitino.catalog.glue.GlueConstants.WAREHOUSE;
+import static
org.apache.gravitino.connector.PropertyEntry.stringOptionalPropertyEntry;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
@@ -43,14 +44,10 @@ import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
-<<<<<<< HEAD
-=======
import java.util.Set;
import java.util.function.Function;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
-import org.apache.gravitino.cloud.storage.AWSPropertiesMetadata;
->>>>>>> 30a11bb0c ([#14516] fix(catalog-glue): Map AWS errors to client-facing
statuses and validate catalog properties (#14517))
import org.apache.gravitino.connector.BaseCatalogPropertiesMetadata;
import org.apache.gravitino.connector.PropertyEntry;
import software.amazon.awssdk.regions.Region;
@@ -90,8 +87,7 @@ public class GlueCatalogPropertiesMetadata extends
BaseCatalogPropertiesMetadata
false /* required */,
true /* immutable */,
null /* defaultValue */,
-<<<<<<< HEAD
- false /* hidden */))
+ GlueCatalogPropertiesMetadata::checkCatalogId))
.put(
AWS_ACCESS_KEY_ID,
stringOptionalPropertyEntry(
@@ -110,11 +106,6 @@ public class GlueCatalogPropertiesMetadata extends
BaseCatalogPropertiesMetadata
false /* immutable */,
null /* defaultValue */,
true /* hidden */))
-=======
- GlueCatalogPropertiesMetadata::checkCatalogId))
- .put(AWS_ACCESS_KEY_ID, AWSPropertiesMetadata.AWS_ACCESS_KEY_ID)
- .put(AWS_SECRET_ACCESS_KEY,
AWSPropertiesMetadata.AWS_SECRET_ACCESS_KEY)
->>>>>>> 30a11bb0c ([#14516] fix(catalog-glue): Map AWS errors to client-facing
statuses and validate catalog properties (#14517))
.put(
AWS_GLUE_ENDPOINT,
stringEntry(
diff --git
a/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueExceptionConverter.java
b/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueExceptionConverter.java
index bf3dbc7089..395934c46e 100644
---
a/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueExceptionConverter.java
+++
b/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueExceptionConverter.java
@@ -27,9 +27,7 @@ import
org.apache.gravitino.exceptions.GravitinoRuntimeException;
import org.apache.gravitino.exceptions.NoSuchSchemaException;
import org.apache.gravitino.exceptions.NoSuchTableException;
import org.apache.gravitino.exceptions.NotFoundException;
-import org.apache.gravitino.exceptions.OptimisticLockException;
import org.apache.gravitino.exceptions.SchemaAlreadyExistsException;
-import org.apache.gravitino.exceptions.ServiceUnavailableException;
import org.apache.gravitino.exceptions.TableAlreadyExistsException;
import org.apache.gravitino.utils.ExceptionMessages;
import org.apache.iceberg.exceptions.CommitFailedException;
@@ -255,7 +253,7 @@ final class GlueExceptionConverter {
awsErrorDetail(glueException));
}
if (e instanceof ThrottlingException ||
glueException.isThrottlingException()) {
- return new ServiceUnavailableException(
+ return new ConnectionFailedException(
e,
"AWS Glue throttled the request for %s; the request can be retried.
AWS error: %s",
context,
@@ -334,9 +332,9 @@ final class GlueExceptionConverter {
* and S3 errors either as its own exception types or wrapped around the AWS
SDK exception, so the
* cause chain is walked from the outside in and the first recognized type
decides the result:
* Iceberg not-found, already-exists, validation and forbidden errors map to
the matching
- * Gravitino types, a commit conflict maps to {@link
OptimisticLockException}, and AWS SDK causes
- * go through {@link #toGenericException}. A commit whose state is unknown
is reported as such,
- * because the change may have been applied. {@link
GravitinoRuntimeException}, {@link
+ * Gravitino types, a commit conflict maps to a retryable {@link
RuntimeException}, and AWS SDK
+ * causes go through {@link #toGenericException}. A commit whose state is
unknown is reported as
+ * such, because the change may have been applied. {@link
GravitinoRuntimeException}, {@link
* IllegalArgumentException} and {@link UnsupportedOperationException} are
returned as is.
*
* @param e the failure raised by an Iceberg catalog call
@@ -368,8 +366,10 @@ final class GlueExceptionConverter {
if (t instanceof CommitFailedException) {
Throwable awsCause = findCause(t, SdkException.class);
return awsCause == null || awsCause instanceof
ConcurrentModificationException
- ? new OptimisticLockException(
- e, "%s: the table was changed concurrently, retry: %s",
context, describe(t))
+ ? new RuntimeException(
+ String.format(
+ "%s: the table was changed concurrently, retry: %s",
context, describe(t)),
+ e)
: toGenericException((SdkException) awsCause, context, null);
}
if (t instanceof AlreadyExistsException) {
diff --git
a/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogCredentials.java
b/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogCredentials.java
index 7ca612c0b3..9cc06efea9 100644
---
a/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogCredentials.java
+++
b/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogCredentials.java
@@ -18,139 +18,14 @@
*/
package org.apache.gravitino.catalog.glue;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.time.Instant;
-import java.util.Arrays;
-import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
-import org.apache.gravitino.Catalog;
-import org.apache.gravitino.Namespace;
-import org.apache.gravitino.credential.AwsSecretKeyCredential;
-import org.apache.gravitino.credential.CredentialConstants;
-import org.apache.gravitino.credential.S3SecretKeyCredential;
-import org.apache.gravitino.credential.S3TokenCredential;
-import org.apache.gravitino.meta.AuditInfo;
-import org.apache.gravitino.meta.CatalogEntity;
-import org.apache.gravitino.storage.S3Properties;
import org.junit.jupiter.api.Test;
public class TestGlueCatalogCredentials {
- @Test
- void testAwsKeysAutoDetectAwsAndS3Providers() {
- Map<String, String> props =
- Map.of(
- GlueConstants.AWS_ACCESS_KEY_ID,
- "AKIA",
- GlueConstants.AWS_SECRET_ACCESS_KEY,
- "secret",
- GlueConstants.AWS_REGION,
- "us-east-1");
-
- CatalogEntity entity =
- CatalogEntity.builder()
- .withId(1L)
- .withName("glue")
- .withNamespace(Namespace.of("metalake"))
- .withType(Catalog.Type.RELATIONAL)
- .withProvider("glue")
- .withProperties(props)
- .withAuditInfo(
-
AuditInfo.builder().withCreator("test").withCreateTime(Instant.now()).build())
- .build();
-
- GlueCatalog catalog = new
GlueCatalog().withCatalogEntity(entity).withCatalogConf(props);
- Map<String, String> withProviders =
catalog.propertiesWithCredentialProviders();
-
- List<String> providers = splitProviders(withProviders);
-
assertTrue(providers.contains(AwsSecretKeyCredential.AWS_SECRET_KEY_CREDENTIAL_TYPE));
-
assertTrue(providers.contains(S3SecretKeyCredential.S3_SECRET_KEY_CREDENTIAL_TYPE));
- assertEquals("AKIA",
withProviders.get(S3Properties.GRAVITINO_S3_ACCESS_KEY_ID));
- assertEquals("secret",
withProviders.get(S3Properties.GRAVITINO_S3_SECRET_ACCESS_KEY));
- assertEquals("AKIA", withProviders.get(GlueConstants.AWS_ACCESS_KEY_ID));
- }
-
- @Test
- void testExplicitCredentialProvidersStillGetsAwsButNotS3SecretKey() {
- Map<String, String> props =
- Map.of(
- GlueConstants.AWS_ACCESS_KEY_ID,
- "AKIA",
- GlueConstants.AWS_SECRET_ACCESS_KEY,
- "secret",
- GlueConstants.AWS_REGION,
- "us-east-1",
- CredentialConstants.CREDENTIAL_PROVIDERS,
- "custom-provider");
-
- CatalogEntity entity =
- CatalogEntity.builder()
- .withId(2L)
- .withName("glue-explicit")
- .withNamespace(Namespace.of("metalake"))
- .withType(Catalog.Type.RELATIONAL)
- .withProvider("glue")
- .withProperties(props)
- .withAuditInfo(
-
AuditInfo.builder().withCreator("test").withCreateTime(Instant.now()).build())
- .build();
-
- GlueCatalog catalog = new
GlueCatalog().withCatalogEntity(entity).withCatalogConf(props);
- Map<String, String> withProviders =
catalog.propertiesWithCredentialProviders();
-
- List<String> providers = splitProviders(withProviders);
- assertEquals(
- List.of("custom-provider",
AwsSecretKeyCredential.AWS_SECRET_KEY_CREDENTIAL_TYPE),
- providers);
-
assertFalse(providers.contains(S3SecretKeyCredential.S3_SECRET_KEY_CREDENTIAL_TYPE));
- assertEquals("AKIA",
withProviders.get(S3Properties.GRAVITINO_S3_ACCESS_KEY_ID));
- }
-
- @Test
- void testExplicitS3TokenDoesNotAppendS3SecretKey() {
- Map<String, String> props =
- Map.of(
- GlueConstants.AWS_ACCESS_KEY_ID,
- "AKIA",
- GlueConstants.AWS_SECRET_ACCESS_KEY,
- "secret",
- GlueConstants.AWS_REGION,
- "us-east-1",
- CredentialConstants.CREDENTIAL_PROVIDERS,
- S3TokenCredential.S3_TOKEN_CREDENTIAL_TYPE);
-
- CatalogEntity entity =
- CatalogEntity.builder()
- .withId(3L)
- .withName("glue-s3-token")
- .withNamespace(Namespace.of("metalake"))
- .withType(Catalog.Type.RELATIONAL)
- .withProvider("glue")
- .withProperties(props)
- .withAuditInfo(
-
AuditInfo.builder().withCreator("test").withCreateTime(Instant.now()).build())
- .build();
-
- GlueCatalog catalog = new
GlueCatalog().withCatalogEntity(entity).withCatalogConf(props);
- Map<String, String> withProviders =
catalog.propertiesWithCredentialProviders();
-
- assertEquals(
- List.of(
- S3TokenCredential.S3_TOKEN_CREDENTIAL_TYPE,
- AwsSecretKeyCredential.AWS_SECRET_KEY_CREDENTIAL_TYPE),
- splitProviders(withProviders));
- }
-
- private static List<String> splitProviders(Map<String, String>
withProviders) {
- String providers =
withProviders.get(CredentialConstants.CREDENTIAL_PROVIDERS);
- return
Arrays.stream(providers.split(",")).map(String::trim).collect(Collectors.toList());
- }
-
@Test
void testValidateOnCreateRunsLocalConfigChecks() {
GlueCatalog catalog =
diff --git
a/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogPropertiesMetadata.java
b/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogPropertiesMetadata.java
index cb53a0e4b1..fab4cbc70e 100644
---
a/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogPropertiesMetadata.java
+++
b/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogPropertiesMetadata.java
@@ -33,11 +33,7 @@ import static
org.apache.gravitino.catalog.glue.GlueConstants.TABLE_FORMAT_FILTE
import static org.apache.gravitino.catalog.glue.GlueConstants.WAREHOUSE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
-<<<<<<< HEAD
-=======
-import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
->>>>>>> 30a11bb0c ([#14516] fix(catalog-glue): Map AWS errors to client-facing
statuses and validate catalog properties (#14517))
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
diff --git
a/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogSchemaOperations.java
b/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogSchemaOperations.java
index d1eb719ee6..6a36ed8d10 100644
---
a/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogSchemaOperations.java
+++
b/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueCatalogSchemaOperations.java
@@ -41,7 +41,6 @@ import org.apache.gravitino.exceptions.ForbiddenException;
import org.apache.gravitino.exceptions.NoSuchSchemaException;
import org.apache.gravitino.exceptions.NonEmptySchemaException;
import org.apache.gravitino.exceptions.SchemaAlreadyExistsException;
-import org.apache.gravitino.exceptions.ServiceUnavailableException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
@@ -236,7 +235,7 @@ class TestGlueCatalogSchemaOperations {
}
@Test
- void testLoadSchemaMapsThrottlingToServiceUnavailable() {
+ void testLoadSchemaMapsThrottlingToConnectionFailed() {
NameIdentifier ident = NameIdentifier.of("metalake", "catalog", "db");
when(mockClient.getDatabase(any(GetDatabaseRequest.class)))
.thenThrow(
@@ -249,8 +248,8 @@ class TestGlueCatalogSchemaOperations {
.build())
.build());
- ServiceUnavailableException ex =
- assertThrows(ServiceUnavailableException.class, () ->
ops.loadSchema(ident));
+ ConnectionFailedException ex =
+ assertThrows(ConnectionFailedException.class, () ->
ops.loadSchema(ident));
assertTrue(ex.getMessage().contains("can be retried"), ex.getMessage());
}
diff --git
a/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueExceptionConverter.java
b/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueExceptionConverter.java
index dd47890432..2c0cc847af 100644
---
a/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueExceptionConverter.java
+++
b/catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueExceptionConverter.java
@@ -29,9 +29,7 @@ import org.apache.gravitino.exceptions.ForbiddenException;
import org.apache.gravitino.exceptions.NoSuchSchemaException;
import org.apache.gravitino.exceptions.NoSuchTableException;
import org.apache.gravitino.exceptions.NotFoundException;
-import org.apache.gravitino.exceptions.OptimisticLockException;
import org.apache.gravitino.exceptions.SchemaAlreadyExistsException;
-import org.apache.gravitino.exceptions.ServiceUnavailableException;
import org.apache.gravitino.exceptions.TableAlreadyExistsException;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.awscore.exception.AwsErrorDetails;
@@ -385,14 +383,15 @@ public class TestGlueExceptionConverter {
}
@Test
- public void testIcebergConcurrentCommitIsConflict() {
+ public void testIcebergConcurrentCommitIsRetryableFailure() {
RuntimeException raw =
new org.apache.iceberg.exceptions.CommitFailedException(
ConcurrentModificationException.builder().message("concurrent
update").build(),
"Cannot commit db.t because Glue detected concurrent update");
- assertInstanceOf(
- OptimisticLockException.class,
GlueExceptionConverter.toIcebergException(raw, "table t"));
+ RuntimeException converted =
GlueExceptionConverter.toIcebergException(raw, "table t");
+ assertEquals(RuntimeException.class, converted.getClass());
+ assertTrue(converted.getMessage().contains("changed concurrently"),
converted.getMessage());
}
@Test
@@ -421,13 +420,12 @@ public class TestGlueExceptionConverter {
}
@Test
- public void testIcebergThrottlingCauseIsServiceUnavailable() {
+ public void testIcebergThrottlingCauseIsConnectionFailed() {
RuntimeException raw =
new RuntimeException(ThrottlingException.builder().message("Rate
exceeded").build());
assertInstanceOf(
- ServiceUnavailableException.class,
- GlueExceptionConverter.toIcebergException(raw, "table t"));
+ ConnectionFailedException.class,
GlueExceptionConverter.toIcebergException(raw, "table t"));
}
@Test
@@ -441,7 +439,7 @@ public class TestGlueExceptionConverter {
}
@Test
- public void testUnmodeledThrottlingStatusIsServiceUnavailable() {
+ public void testUnmodeledThrottlingStatusIsConnectionFailed() {
GlueException tooMany =
(GlueException)
GlueException.builder()
@@ -455,7 +453,7 @@ public class TestGlueExceptionConverter {
.build();
assertInstanceOf(
- ServiceUnavailableException.class,
+ ConnectionFailedException.class,
GlueExceptionConverter.toClientException(tooMany, "table t", null));
}
diff --git
a/server/src/test/java/org/apache/gravitino/server/web/rest/TestExceptionHandlers.java
b/server/src/test/java/org/apache/gravitino/server/web/rest/TestExceptionHandlers.java
index e75e6f64e6..cd1fdc977a 100644
---
a/server/src/test/java/org/apache/gravitino/server/web/rest/TestExceptionHandlers.java
+++
b/server/src/test/java/org/apache/gravitino/server/web/rest/TestExceptionHandlers.java
@@ -22,18 +22,9 @@ import java.util.List;
import javax.ws.rs.core.Response;
import org.apache.gravitino.dto.responses.ErrorConstants;
import org.apache.gravitino.dto.responses.ErrorResponse;
-<<<<<<< HEAD
import org.apache.gravitino.exceptions.ConnectionFailedException;
import org.apache.gravitino.exceptions.ForbiddenException;
import org.apache.gravitino.exceptions.NoSuchSchemaException;
-=======
-import org.apache.gravitino.exceptions.ForbiddenException;
-import org.apache.gravitino.exceptions.InUseException;
-import org.apache.gravitino.exceptions.NoSuchJobTemplateException;
-import org.apache.gravitino.exceptions.NoSuchMetalakeException;
-import org.apache.gravitino.exceptions.OptimisticLockException;
-import org.apache.gravitino.exceptions.ServiceUnavailableException;
->>>>>>> 30a11bb0c ([#14516] fix(catalog-glue): Map AWS errors to client-facing
statuses and validate catalog properties (#14517))
import org.apache.gravitino.exceptions.UnmodifiableStatisticException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -107,40 +98,6 @@ public class TestExceptionHandlers {
Assertions.assertEquals("", msg6);
}
- @Test
-<<<<<<< HEAD
-=======
- public void testOptimisticLockConflictReturnsConflict() {
- Response response =
- ExceptionHandlers.handleTableException(
- OperationType.ALTER,
- "table",
- "schema",
- new OptimisticLockException("The table was modified
concurrently"));
-
- Assertions.assertEquals(Response.Status.CONFLICT.getStatusCode(),
response.getStatus());
- ErrorResponse errorResponse = (ErrorResponse) response.getEntity();
- Assertions.assertEquals(ErrorConstants.OPTIMISTIC_LOCK_CONFLICT_CODE,
errorResponse.getCode());
- Assertions.assertEquals(OptimisticLockException.class.getSimpleName(),
errorResponse.getType());
- }
-
- @Test
- public void testServiceUnavailableReturnsServiceUnavailable() {
- Response response =
- ExceptionHandlers.handleTableException(
- OperationType.LOAD,
- "table",
- "schema",
- new ServiceUnavailableException("secret provider 'vault' is
unavailable"));
-
- Assertions.assertEquals(
- Response.Status.SERVICE_UNAVAILABLE.getStatusCode(),
response.getStatus());
- ErrorResponse errorResponse = (ErrorResponse) response.getEntity();
- Assertions.assertEquals(ErrorConstants.SERVICE_UNAVAILABLE_CODE,
errorResponse.getCode());
- Assertions.assertEquals(
- ServiceUnavailableException.class.getSimpleName(),
errorResponse.getType());
- }
-
@Test
void testPartitionForbiddenReturnsForbidden() {
Response response =
@@ -157,7 +114,6 @@ public class TestExceptionHandlers {
}
@Test
->>>>>>> 30a11bb0c ([#14516] fix(catalog-glue): Map AWS errors to client-facing
statuses and validate catalog properties (#14517))
void testUnsupportedOperationReturnsNotImplemented() {
UnsupportedOperationException exception =
new UnsupportedOperationException("Operation is not supported");