You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by "eric-maynard (via GitHub)" <gi...@apache.org> on 2024/09/19 22:00:41 UTC
[PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
eric-maynard opened a new pull request, #309:
URL: https://github.com/apache/polaris/pull/309
# Description
Previously DefaultContextResolver would always use `default-realm` as the default realm regardless of the configuration for `defaultRealm`. This PR fixes this behavior.
Fixes #281
## Type of change
Please delete options that are not relevant.
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Documentation update
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
# Checklist:
Please delete options that are not relevant.
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on code in PR #309:
URL: https://github.com/apache/polaris/pull/309#discussion_r1792847144
##########
polaris-service/src/main/java/org/apache/polaris/service/config/PolarisApplicationConfig.java:
##########
@@ -91,6 +91,7 @@ public void setPolarisAuthenticator(
}
public RealmContextResolver getRealmContextResolver() {
+ realmContextResolver.setDefaultRealm(this.defaultRealm);
return realmContextResolver;
Review Comment:
If we made the above change, I think we don't have to make the interface change 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;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain merged PR #309:
URL: https://github.com/apache/polaris/pull/309
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on code in PR #309:
URL: https://github.com/apache/polaris/pull/309#discussion_r1792848350
##########
polaris-service/src/main/java/org/apache/polaris/service/context/DefaultContextResolver.java:
##########
@@ -92,14 +92,22 @@ public RealmContext resolveRealmContext(
if (!parsedProperties.containsKey(REALM_PROPERTY_KEY)) {
LOGGER.warn(
- "Failed to parse {} from headers; using {}",
- REALM_PROPERTY_KEY,
- REALM_PROPERTY_DEFAULT_VALUE);
- parsedProperties.put(REALM_PROPERTY_KEY, REALM_PROPERTY_DEFAULT_VALUE);
+ "Failed to parse {} from headers; using {}", REALM_PROPERTY_KEY, getDefaultRealm());
+ parsedProperties.put(REALM_PROPERTY_KEY, getDefaultRealm());
}
return () -> parsedProperties.get(REALM_PROPERTY_KEY);
}
+ @Override
+ public void setDefaultRealm(String defaultRealm) {
+ this.defaultRealm = defaultRealm;
+ }
+
+ @Override
+ public String getDefaultRealm() {
+ return this.defaultRealm;
+ }
Review Comment:
Can we remove this method if it is only used within this class?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on code in PR #309:
URL: https://github.com/apache/polaris/pull/309#discussion_r1792847144
##########
polaris-service/src/main/java/org/apache/polaris/service/config/PolarisApplicationConfig.java:
##########
@@ -91,6 +91,7 @@ public void setPolarisAuthenticator(
}
public RealmContextResolver getRealmContextResolver() {
+ realmContextResolver.setDefaultRealm(this.defaultRealm);
return realmContextResolver;
Review Comment:
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?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #309:
URL: https://github.com/apache/polaris/pull/309#discussion_r1793701041
##########
polaris-service/src/main/java/org/apache/polaris/service/config/PolarisApplicationConfig.java:
##########
@@ -91,6 +91,7 @@ public void setPolarisAuthenticator(
}
public RealmContextResolver getRealmContextResolver() {
+ realmContextResolver.setDefaultRealm(this.defaultRealm);
return realmContextResolver;
Review Comment:
Removing the default constructor is still a breaking change, so is this materially better?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "sfc-gh-ygu (via GitHub)" <gi...@apache.org>.
sfc-gh-ygu commented on code in PR #309:
URL: https://github.com/apache/polaris/pull/309#discussion_r1793944446
##########
polaris-service/src/main/java/org/apache/polaris/service/config/PolarisApplicationConfig.java:
##########
@@ -91,6 +91,7 @@ public void setPolarisAuthenticator(
}
public RealmContextResolver getRealmContextResolver() {
+ realmContextResolver.setDefaultRealm(this.defaultRealm);
return realmContextResolver;
Review Comment:
It is cleaner solution unless the config `defaultRealm` would be used by other places than `RealmContextResolver`. Do we?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #309:
URL: https://github.com/apache/polaris/pull/309#discussion_r1793703161
##########
polaris-service/src/main/java/org/apache/polaris/service/context/DefaultContextResolver.java:
##########
@@ -92,14 +92,22 @@ public RealmContext resolveRealmContext(
if (!parsedProperties.containsKey(REALM_PROPERTY_KEY)) {
LOGGER.warn(
- "Failed to parse {} from headers; using {}",
- REALM_PROPERTY_KEY,
- REALM_PROPERTY_DEFAULT_VALUE);
- parsedProperties.put(REALM_PROPERTY_KEY, REALM_PROPERTY_DEFAULT_VALUE);
+ "Failed to parse {} from headers; using {}", REALM_PROPERTY_KEY, getDefaultRealm());
+ parsedProperties.put(REALM_PROPERTY_KEY, getDefaultRealm());
}
return () -> parsedProperties.get(REALM_PROPERTY_KEY);
}
+ @Override
+ public void setDefaultRealm(String defaultRealm) {
+ this.defaultRealm = defaultRealm;
+ }
+
+ @Override
+ public String getDefaultRealm() {
+ return this.defaultRealm;
+ }
Review Comment:
I don't think we should keep the setter but not the getter
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #309:
URL: https://github.com/apache/polaris/pull/309#discussion_r1797250025
##########
polaris-service/src/main/java/org/apache/polaris/service/config/PolarisApplicationConfig.java:
##########
@@ -91,6 +91,7 @@ public void setPolarisAuthenticator(
}
public RealmContextResolver getRealmContextResolver() {
+ realmContextResolver.setDefaultRealm(this.defaultRealm);
return realmContextResolver;
Review Comment:
The `defaultRealm` is just the default realm used by `RealmContextResolver` when the realm cannot be parsed from the request
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "Gerrit-K (via GitHub)" <gi...@apache.org>.
Gerrit-K commented on PR #309:
URL: https://github.com/apache/polaris/pull/309#issuecomment-2557391627
Hey @flyrain and @eric-maynard, sorry to ask, but did this fix work after all? 🤔 I don't see any unit/integration tests attached to the PR and when I set the attribute in my config (in the Helm chart):
```
polarisServerConfig:
defaultRealm: something
```
I get an exception on startup:
```
io.dropwizard.configuration.ConfigurationParsingException: /app/config/polaris-server.yml has an error:
* Failed to parse configuration at: defaultRealm; Cannot invoke "org.apache.polaris.service.context.RealmContextResolver.setDefaultRealm(String)" because "this.realmContextResolver" is null (through reference chain: org.apache.polaris.service.dropwizard.config.PolarisApplicationConfig["defaultRealm"])
at io.dropwizard.configuration.ConfigurationParsingException$Builder.build(ConfigurationParsingException.java:277)
at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:177)
at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:94)
at io.dropwizard.core.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:139)
at io.dropwizard.core.cli.ConfiguredCommand.run(ConfiguredCommand.java:85)
at io.dropwizard.core.cli.Cli.run(Cli.java:78)
at io.dropwizard.core.Application.run(Application.java:94)
at org.apache.polaris.service.dropwizard.PolarisApplication.main(PolarisApplication.java:153)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Cannot invoke "org.apache.polaris.service.context.RealmContextResolver.setDefaultRealm(String)" because "this.realmContextResolver" is null (through reference chain: org.apache.polaris.service.dropwizard.config.PolarisApplicationConfig["defaultRealm"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:402)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:361)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1964)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:275)
at com.fasterxml.jackson.module.blackbird.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:155)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:4893)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3036)
at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:148)
... 6 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.polaris.service.context.RealmContextResolver.setDefaultRealm(String)" because "this.realmContextResolver" is null
at org.apache.polaris.service.dropwizard.config.PolarisApplicationConfig.setDefaultRealm(PolarisApplicationConfig.java:312)
at com.fasterxml.jackson.module.blackbird.deser.SettableStringProperty.set(SettableStringProperty.java:56)
at com.fasterxml.jackson.module.blackbird.deser.SettableStringProperty.deserializeAndSet(SettableStringProperty.java:41)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:273)
... 11 more
```
Am I missing something in the config? Or is this maybe a regression?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on PR #309:
URL: https://github.com/apache/polaris/pull/309#issuecomment-2558166005
@Gerrit-K you might be experiencing the bug described in #562.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "Gerrit-K (via GitHub)" <gi...@apache.org>.
Gerrit-K commented on PR #309:
URL: https://github.com/apache/polaris/pull/309#issuecomment-2559114625
Oh, you're right! Sorry, I must have somehow missed that 🙇
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on code in PR #309:
URL: https://github.com/apache/polaris/pull/309#discussion_r1800256439
##########
polaris-service/src/main/java/org/apache/polaris/service/config/PolarisApplicationConfig.java:
##########
@@ -91,6 +91,7 @@ public void setPolarisAuthenticator(
}
public RealmContextResolver getRealmContextResolver() {
+ realmContextResolver.setDefaultRealm(this.defaultRealm);
return realmContextResolver;
Review Comment:
Synced with @eric-maynard offline, we agreed on pushing this break change to another PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #309:
URL: https://github.com/apache/polaris/pull/309#discussion_r1793702094
##########
polaris-service/src/main/java/org/apache/polaris/service/config/PolarisApplicationConfig.java:
##########
@@ -91,6 +91,7 @@ public void setPolarisAuthenticator(
}
public RealmContextResolver getRealmContextResolver() {
+ realmContextResolver.setDefaultRealm(this.defaultRealm);
return realmContextResolver;
Review Comment:
Also, to be clear, we are not just changing how this works for `DefaultContextResolver` but for all `RealmContextResolver` implementations
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] DefaultContextResolver should respect the defaultRealm configuration [polaris]
Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on PR #309:
URL: https://github.com/apache/polaris/pull/309#issuecomment-2423420041
Thanks @eric-maynard for the fix!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org