-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a command to explicitly purge the metastore #59
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on the fence with some --overwrite
flag that purges (some) state.
bootstrap
is a one-off operation that, I think, should fail when the system's already bootstrapped.
I think, it's better to have an explicit command or tool to purge / reset to avoid accidentally resetting principals. WDYT?
Thanks for taking a look @snazy -- to be clear, the current behavior is that bootstrap will silently purge the state. This PR proposes a flag you have to set in order to confirm that you really want to do this. And without that flag bootstrap will fail when the system is already bootstrapped. |
Oh - right - that "bark at you" code part is new. Can we add the "barking" part and have a "purge root-principals" command or so? |
I feel that's a bit safer - humans tend to be lazy (and forget that they have such |
// While bootstrapping we need to act as a fake privileged context since the real | ||
// CallContext hasn't even been resolved yet. | ||
PolarisCallContext polarisContext = | ||
new PolarisCallContext( | ||
sessionSupplierMap.get(realmContext.getRealmIdentifier()).get(), diagServices); | ||
CallContext.setCurrentContext(CallContext.of(realmContext, polarisContext)); | ||
|
||
if (!overwrite) { | ||
PolarisMetaStoreManager.EntityResult preliminaryRootPrincipalLookup = | ||
metaStoreManager.readEntityByName( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be version safe in the future? For now I assume this is safe but in the future could readEntityByName fail for a Polaris catalog bootstrapped from an earlier version?
This seems like a good check to have for now, I'm just more worried about what happens if this call fails because the current version of Polaris just doesn't understand how to look up the Principal in the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an important concern and it's why we don't rely on a check like this to auto-bootstrap... but it seems to me that this check is much less critical. That scenario would be very bad for other reasons, but here you would only be losing the protection of the --overwrite
flag.
polaris-core/src/main/java/io/polaris/core/persistence/MetaStoreManagerFactory.java
Show resolved
Hide resolved
@snazy I think we probably can't safely always validate (or require that an implementation can validate) that existing information is in the destination. I like this though because it is at least safer than the current behavior. |
Sure, having this check is definitely a good thing. What I'm thinking of is:
Thinking of humans leaving the |
I don't think we want to break bootstrap into purge + bootstrap. Not all metastore managers will necessarily purge on bootstrap. We want to just gate bootstrapping behind an additional flag on a best-effort basis in the case that we detect bootstrapping may have already been performed.
|
IDK, I like the option to If |
Thanks for taking a look @collado-mike & @snazy -- I have implemented a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit, but overall LGTM.
Deferring review to @collado-mike, because this related code base a bit better ;)
polaris-core/src/main/java/io/polaris/core/persistence/MetaStoreManagerFactory.java
Show resolved
Hide resolved
polaris-core/src/main/java/io/polaris/core/persistence/PolarisMetaStoreManager.java
Show resolved
Hide resolved
polaris-core/src/main/java/io/polaris/core/persistence/PolarisMetaStoreManagerImpl.java
Show resolved
Hide resolved
polaris-service/src/main/java/io/polaris/service/BootstrapRealmsCommand.java
Outdated
Show resolved
Hide resolved
polaris-service/src/main/java/io/polaris/service/PurgeRealmsCommand.java
Outdated
Show resolved
Hide resolved
polaris-service/src/main/java/io/polaris/service/BootstrapRealmsCommand.java
Outdated
Show resolved
Hide resolved
Head branch was pushed to by a user without write access
@flyrain can we have this merge if not other blockers so the bootstrap won't wipe the backend if accidently got ran more than once. Then I can test if anything additional will be needed on the helm side as well to handle those. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor comments.
Map<String, PolarisMetaStoreManager.PrincipalSecretsResult> results = | ||
metaStoreManagerFactory.bootstrapRealms(configuration.getDefaultRealms()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we can use var
to simplify a bit.
for (Map.Entry<String, PolarisMetaStoreManager.PrincipalSecretsResult> result : | ||
results.entrySet()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We can use var
to simplify and keep them in one line
I haven’t seen any use of `var` outside of tests in this project; might
there be compatibility concerns? Is this merge blocking?
…On Sat, Aug 17, 2024 at 6:20 PM Yufei Gu ***@***.***> wrote:
***@***.**** approved this pull request.
LGTM with minor comments.
------------------------------
In
polaris-service/src/main/java/io/polaris/service/BootstrapRealmsCommand.java
<#59 (comment)>
:
> + Map<String, PolarisMetaStoreManager.PrincipalSecretsResult> results =
+ metaStoreManagerFactory.bootstrapRealms(configuration.getDefaultRealms());
Nit: we can use var to simplify a bit.
------------------------------
In
polaris-service/src/main/java/io/polaris/service/BootstrapRealmsCommand.java
<#59 (comment)>
:
> + for (Map.Entry<String, PolarisMetaStoreManager.PrincipalSecretsResult> result :
+ results.entrySet()) {
Nit: We can use var to simplify and keep them in one line
—
Reply to this email directly, view it on GitHub
<#59 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFRE3SGK6EGIGJAZYNFAK6DZR7EDDAVCNFSM6AAAAABL27URICVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDENBUGE2TOOJYGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I think it's fine to use |
Thanks @eric-maynard for the change. Thanks @collado-mike @snazy @RussellSpitzer @MonkeyCanCode for the review. |
Description
This adds a new command,
purge
, that must be run in order to purge entities from the metastore.Additionally, bootstrapping will now fail if entities exist in the metastore instead of purging them.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Previous behavior:
New behavior:
New behavior + purge:
Checklist: