+
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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

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.

ryanemerson and others added 5 commits July 9, 2025 12:00
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>
Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
Closes keycloak#41138

Signed-off-by: Ryan Emerson <remerson@redhat.com>
@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:


@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.


@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.

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浏览器服务,不要输入任何密码和下载