+
Skip to content

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

Conversation

ryanemerson
Copy link
Contributor

@ryanemerson ryanemerson commented Jul 15, 2025

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 the UpdateCompatibility command.

Given that we state the following in the docs, ^ limitation could be considered acceptable:

Ensure that all configuration options, whether set via environment variables or CLI arguments, are included when running this command.

@keycloak-github-bot
Copy link

Unreported flaky test detected

If 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

Keycloak CI - Base IT (5)

org.openqa.selenium.TimeoutException: 
java.net.SocketTimeoutException: Read timed out
Build info: version: '4.28.1', revision: '73f5ad48a2'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.11.0-1018-azure', java.version: '21.0.7'
Driver info: driver.version: HtmlUnitDriver
...

Report flaky test

org.keycloak.testsuite.federation.ldap.LDAPReadOnlyTest#testReadOnlyUserGetsPermanentlyLocked

Keycloak CI - Base IT (5)

java.lang.AssertionError
	at org.junit.Assert.fail(Assert.java:87)
	at org.junit.Assert.assertTrue(Assert.java:42)
	at org.junit.Assert.assertFalse(Assert.java:65)
	at org.junit.Assert.assertFalse(Assert.java:75)
...

Report flaky test

Copy link

@keycloak-github-bot keycloak-github-bot bot left a 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

Copy link
Contributor

@pruivo pruivo left a 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;
Copy link
Contributor

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:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I was undecided about this as we don't require it yet, but no harm to future proof.


@Override
public Map<String, String> metadata() {
if (!enabled)
Copy link
Contributor

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.

/**
* 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()),
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I hadn't considered that


@Override
public Map<String, String> meta() {
return Map.of("persistence", Boolean.toString(MultiSiteUtils.isPersistentSessionsEnabled()));
Copy link
Contributor

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking

Suggested change
protected Map<String, String> meta() {
protected Map<String, String> customMetadata() {


@Override
public String getId() {
return spi;
Copy link
Contributor

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 keycloak#41138

Signed-off-by: Ryan Emerson <remerson@redhat.com>
…ider

Signed-off-by: Ryan Emerson <remerson@redhat.com>
Signed-off-by: Ryan Emerson <remerson@redhat.com>
Signed-off-by: Ryan Emerson <remerson@redhat.com>
…ompatibilityMetadataProvider

Signed-off-by: Ryan Emerson <remerson@redhat.com>
Signed-off-by: Ryan Emerson <remerson@redhat.com>
@ryanemerson ryanemerson force-pushed the 41138/cache_cli_option_compatibility_metadata_provider branch from 2e4811a to a23a7e5 Compare July 16, 2025 15:36
@ryanemerson ryanemerson marked this pull request as ready for review July 16, 2025 15:36
@ryanemerson ryanemerson requested review from a team as code owners July 16, 2025 15:36
@ryanemerson
Copy link
Contributor Author

Thanks for the review @pruivo, I believe I have addressed all comments.

@ahus1 ahus1 requested a review from pruivo July 16, 2025 16:02
Copy link
Contributor

@ahus1 ahus1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving based on previous reviews

@ahus1 ahus1 merged commit 4bb0230 into keycloak:main Jul 16, 2025
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement CompatibilityMetadataProvider for Cache CLI args
3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载