Kafka Connect: Handle AccessDeniedException in auto-create (#13758)#16072
Open
yadavay-amzn wants to merge 1 commit intoapache:mainfrom
Open
Kafka Connect: Handle AccessDeniedException in auto-create (#13758)#16072yadavay-amzn wants to merge 1 commit intoapache:mainfrom
yadavay-amzn wants to merge 1 commit intoapache:mainfrom
Conversation
) GlueCatalog.createNamespace() did not catch AccessDeniedException from the AWS Glue SDK. When a user lacks glue:CreateDatabase permission, Glue throws AccessDeniedException (HTTP 400) which propagated uncaught, crashing the Kafka Connect connector even when the database already exists. This fix: - Catches AccessDeniedException in GlueCatalog.createNamespace() and wraps it as ForbiddenException, consistent with how GlueTableOperations already handles this exception. - Adds NotAuthorizedException to the catch block in IcebergWriterFactory.createNamespaceIfNotExist() for defense-in-depth against auth exceptions from any catalog implementation. Closes apache#13758
eac974f to
4a1977d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #13758.
When
iceberg.tables.auto-create-enabledis set, the Kafka Connect sink connector callsGlueCatalog.createNamespace()which can throwsoftware.amazon.awssdk.services.glue.model.AccessDeniedExceptionif the user lacksglue:CreateDatabasepermission. This exception was not caught, crashing the connector even when the database already exists.Changes
Root cause fix —
GlueCatalog.createNamespace():AccessDeniedExceptionand wrap it as Iceberg'sForbiddenException, consistent with howGlueTableOperationsalready handles this exception for table operations.Defense-in-depth —
IcebergWriterFactory.createNamespaceIfNotExist():NotAuthorizedExceptionto the existing catch block alongsideAlreadyExistsExceptionandForbiddenException, so auth exceptions from any catalog implementation are handled gracefully.Testing
testCreateNamespaceAccessDeniedinTestGlueCatalog— verifiesAccessDeniedExceptionis wrapped asForbiddenException.testCreateNamespaceHandlesForbiddenExceptionandtestCreateNamespaceHandlesNotAuthorizedExceptioninTestIcebergWriterFactory— verifies both exception types are swallowed during namespace creation.