mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-10 15:32:05 -03:30
Skip configuring jdbc-ping stack in local mode
Closes #42047 Signed-off-by: Pedro Ruivo <1492066+pruivo@users.noreply.github.com> Co-authored-by: Pedro Ruivo <1492066+pruivo@users.noreply.github.com>
This commit is contained in:
parent
8f326750e8
commit
61e488bbf0
@ -223,7 +223,9 @@ public class DefaultCacheEmbeddedConfigProviderFactory implements CacheEmbeddedC
|
||||
CacheConfigurator.configureNumOwners(config, holder);
|
||||
CacheConfigurator.validateWorkCacheConfiguration(holder);
|
||||
CacheConfigurator.ensureMinimumOwners(holder);
|
||||
KeycloakModelUtils.runJobInTransaction(factory, session -> JGroupsConfigurator.configureJGroups(config, holder, session));
|
||||
if (JGroupsConfigurator.isClustered(holder)) {
|
||||
KeycloakModelUtils.runJobInTransaction(factory, session -> JGroupsConfigurator.configureJGroups(config, holder, session));
|
||||
}
|
||||
configureMetrics(config, holder);
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@ import static org.infinispan.configuration.global.TransportConfiguration.STACK;
|
||||
import static org.keycloak.config.CachingOptions.CACHE_EMBEDDED_PREFIX;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.net.InetAddress;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.Connection;
|
||||
@ -100,6 +99,26 @@ public final class JGroupsConfigurator {
|
||||
ClassConfigurator.add(TracerHeader.ID, TracerHeader.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if Infinispan is configured with or without a clustering.
|
||||
*
|
||||
* @param holder The {@link ConfigurationBuilderHolder} with the Infinispan configuration.
|
||||
* @return {@code true} if Infinispan is configured without clustering.
|
||||
*/
|
||||
public static boolean isLocal(ConfigurationBuilderHolder holder) {
|
||||
return transportOf(holder).getTransport() == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if Infinispan is configured with or without a clustering.
|
||||
*
|
||||
* @param holder The {@link ConfigurationBuilderHolder} with the Infinispan configuration.
|
||||
* @return {@code true} if Infinispan is configured with clustering enabled.
|
||||
*/
|
||||
public static boolean isClustered(ConfigurationBuilderHolder holder) {
|
||||
return transportOf(holder).getTransport() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures JGroups based on the Keycloak configuration.
|
||||
*
|
||||
@ -108,6 +127,9 @@ public final class JGroupsConfigurator {
|
||||
* @param session The {@link KeycloakSession} sessions for Database access.
|
||||
*/
|
||||
public static void configureJGroups(Config.Scope config, ConfigurationBuilderHolder holder, KeycloakSession session) {
|
||||
if (isLocal(holder)) {
|
||||
return;
|
||||
}
|
||||
var stack = config.get(DefaultCacheEmbeddedConfigProviderFactory.STACK);
|
||||
if (stack != null) {
|
||||
transportOf(holder).stack(stack);
|
||||
|
||||
@ -158,6 +158,9 @@ public class ClusterConfigDistTest {
|
||||
void testStartDevDefaultsToLocalCaches(CLIResult result) {
|
||||
result.assertStartedDevMode();
|
||||
result.assertLocalCache();
|
||||
result.assertNoMessage("JGroups JDBC_PING discovery enabled");
|
||||
result.assertNoMessage("JGroups Encryption enabled.");
|
||||
result.assertNoMessage("Starting JGroups certificate reload manager");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -195,6 +198,16 @@ public class ClusterConfigDistTest {
|
||||
result.assertNoMessage(WARN_DEFAULT_CACHE_MUTATIONS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Launch({ "start", "--cache=local", "--http-enabled=true", "--hostname-strict=false"})
|
||||
void testNotClustered(CLIResult result) {
|
||||
result.assertStarted();
|
||||
result.assertLocalCache();
|
||||
result.assertNoMessage("JGroups JDBC_PING discovery enabled");
|
||||
result.assertNoMessage("JGroups Encryption enabled.");
|
||||
result.assertNoMessage("Starting JGroups certificate reload manager");
|
||||
}
|
||||
|
||||
public static class ConfigureCacheUsingAsyncEncryption implements Consumer<KeycloakDistribution> {
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user