-
Notifications
You must be signed in to change notification settings - Fork 124
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
DefaultContextResolver should respect the defaultRealm configuration #309
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.
Thanks @eric-maynard for working on it! Left some comments. Let me know if they make sense. Also this changes the behavior a bit, I believe it's worthwhile to add a test.
realmContextResolver.setDefaultRealm(this.defaultRealm); | ||
return realmContextResolver; |
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.
Can we combine these two fields(defaultRealm
, realmContextResolver
) to one? I don't see a reason to keep both of them. I'd prefer to keep the resolver, which may have different implementations.
What we can do is to mimic the rate limiter. The default realm name can be picked up by the implementation itself, instead of setting a string field then pass it to the resolver.
@JsonProperty("rateLimiter")
public RateLimiter getRateLimiter() {
return rateLimiter;
}
@JsonProperty("rateLimiter")
public void setRateLimiter(@Nullable RateLimiter rateLimiter) {
this.rateLimiter = rateLimiter;
}
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 confused by this suggestion; the linked issue is about users not being able to pass an explicit string default via the config. Are you suggesting that we remove the config?
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.
ah, I wasn't clear in the first place. I think we can combine these two configs to one.
realmContextResolver:
type: default
defaultRealms:
- default-realm
To
realmContextResolver:
type: default
defaultRealms: default-realm
With that, we don't have to keep two fields in the config class, and I think it is a nice way to manage the lifecycle of realmContextResolver
. It could be immutable object without any setting methods.
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.
If we made the above change, I think we don't have to make the interface changes in RealmContextResolver
. We just need to add a constructor in the class DefaultContextResolver
like this
public DefaultContextResolver( @JsonProperty("defaultRealms") final String defaultRealm) {
this.defaultRealm = defaultRealm;
}
Not setter and getter are needed in this way. WDYT?
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.
Removing the default constructor is still a breaking change, so is this materially better?
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.
Also, to be clear, we are not just changing how this works for DefaultContextResolver
but for all RealmContextResolver
implementations
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.
It is cleaner solution unless the config defaultRealm
would be used by other places than RealmContextResolver
. Do we?
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.
The defaultRealm
is just the default realm used by RealmContextResolver
when the realm cannot be parsed from the request
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.
Synced with @eric-maynard offline, we agreed on pushing this break change to another PR.
polaris-service/src/main/java/org/apache/polaris/service/context/DefaultContextResolver.java
Outdated
Show resolved
Hide resolved
polaris-service/src/main/java/org/apache/polaris/service/context/RealmContextResolver.java
Outdated
Show resolved
Hide resolved
polaris-service/src/main/java/org/apache/polaris/service/context/DefaultContextResolver.java
Show resolved
Hide resolved
Thanks @eric-maynard for the fix! |
Description
Previously DefaultContextResolver would always use
default-realm
as the default realm regardless of the configuration fordefaultRealm
. This PR fixes this behavior.Fixes #281
Type of change
Please delete options that are not relevant.
Checklist:
Please delete options that are not relevant.