Fix catalog create secret cleanup#4974
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents leaked inline external-catalog credentials (OAuth client secret / bearer token) when external catalog creation fails after secrets have already been written to UserSecretsManager.
Changes:
- Track
SecretReferences created during external catalog creation and delete them on any catalog-creation failure path. - Ensure secret-cleanup failures are logged but do not mask the original catalog-creation failure.
- Add unit tests covering cleanup on
AlreadyExistsand unexpected failure, and no cleanup on success.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java | Adds failure-path secret reference cleanup via try/finally around external catalog creation and metastore create. |
| runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAdminServiceTest.java | Adds tests to verify secrets are deleted on failed create (and not deleted on success), including cleanup-failure resilience. |
iting0321
force-pushed
the
fix-catalog-create-secret-cleanup
branch
from
July 5, 2026 10:27
940b4e9 to
a6b2f39
Compare
dimas-b
previously approved these changes
Jul 7, 2026
| LOGGER | ||
| .atWarn() | ||
| .setCause(e) | ||
| .addKeyValue("secretReference", secretReference.urn()) |
Contributor
There was a problem hiding this comment.
nit: Is it useful without being referenced in the message?
Contributor
Author
There was a problem hiding this comment.
Thanks for your feedback! I just updated the message to reference the URN directly while keeping the structured field for filtering and correlation.
dimas-b
previously approved these changes
Jul 8, 2026
dimas-b
left a comment
Contributor
There was a problem hiding this comment.
Please fix merge conflicts 😅
iting0321
force-pushed
the
fix-catalog-create-secret-cleanup
branch
from
July 9, 2026 04:44
b595924 to
c347960
Compare
dimas-b
approved these changes
Jul 9, 2026
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
Solve the TODO for
// TODO: Proactive garbage-collection of any inline secrets that were written to the secrets manager, here and on any other unexpected exception as well.Clean up inline external catalog secrets when catalog creation fails.
External catalog creation can write inline OAuth or bearer credentials to
UserSecretsManagerbefore the catalog entity is created in the metastore.If catalog creation then fails, those stored secrets could be left behind without a catalog referencing them.
This change tracks the
SecretReferences produced during catalog creation and deletes them if the catalog is not successfully created.Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)