-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Implement CompatibilityMetadataProvider for Cache CLI args #41163
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
base: main
Are you sure you want to change the base?
Implement CompatibilityMetadataProvider for Cache CLI args #41163
Conversation
Closes keycloak#41022 Signed-off-by: Ryan Emerson <remerson@redhat.com>
Signed-off-by: Ryan Emerson <remerson@redhat.com>
Signed-off-by: Ryan Emerson <remerson@redhat.com>
Closes keycloak#41138 Signed-off-by: Ryan Emerson <remerson@redhat.com>
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.federation.kerberos.KerberosLdapCrossRealmTrustTest#test03SpnegoLoginUsernamePassword
org.keycloak.testsuite.federation.ldap.LDAPReadOnlyTest#testReadOnlyUserGetsPermanentlyLocked
|
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.
Unreported flaky test detected, please review
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.
Overall, it looks good to me. I left some suggestions anticipating some future work around the SPI options.
public AbstractCompatibilityMetadataProvider(String spi, boolean enabled) { | ||
this.spi = spi; | ||
this.enabled = enabled; | ||
this.config = enabled ? Config.scope(spi, "default") : null; |
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.
Not all providers have the ID default
. I would add the providerId
as a parameter to make this class future-proof.
For example, this factory has SPI optoins and the provider ID is not default
:
Line 313 in 9322d71
return InfinispanUtils.EMBEDDED_PROVIDER_ID; |
|
||
@Override | ||
public Map<String, String> metadata() { | ||
if (!enabled) |
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 would remove the enabled
field and create an abstract method isEnabled(Config.Scope)
.
The provider factory API has the Config.Scope
as a parameter; it can use an SPI option/configuration to decide if it is enabled or not.
Lines 30 to 36 in 3e0a185
/** | |
* Check if the provider is supported and should be available based on the provider configuration. | |
* | |
* @param config the provider configuration | |
* @return {@code true} if the provider is supported. Otherwise, {@code false}. | |
*/ | |
boolean isSupported(Config.Scope config); |
@Override | ||
public Map<String, String> meta() { | ||
return Map.of( | ||
"persistence", Boolean.toString(MultiSiteUtils.isPersistentSessionsEnabled()), |
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 can be removed as the Feature
is already tracked.
|
||
@Override | ||
public Map<String, String> meta() { | ||
return Map.of("persistence", Boolean.toString(MultiSiteUtils.isPersistentSessionsEnabled())); |
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.
hmm, I think we can remove it here too.
return spi; | ||
} | ||
|
||
protected Map<String, String> meta() { |
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.
nitpicking
protected Map<String, String> meta() { | |
protected Map<String, String> customMetadata() { |
|
||
@Override | ||
public String getId() { | ||
return spi; |
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 not sure if this should be a combination of SPI and the Provider ID. For example, InfinispanUserSessionProviderFactory
and RemoteUserSessionProviderFactory
both implement the same SPI.
But let's leave it as is for now.
Closes #41138
Requires #41027
A limitation with the current implementation is that if a default value is not set for a CLI arg then explicitly setting the value will be classes as "incompatible" even though the semantics are the same. For example, the default cache configuration uses the "jdbc-ping" stack, however
--cache-stack jdbc-ping
is not set. So if the user executes the update command with--cache-stack jdbc-ping
explicitly configured then a RECREATE exit code will be returned by theUpdateCompatibility
command.Given that we state the following in the docs, ^ limitation could be considered acceptable: