fix: further refining when profile info is logged (#42483)

closes: #42334

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
Steven Hawkins 2025-09-11 12:17:01 -04:00 committed by GitHub
parent 6ea3c8aedf
commit 3724409c5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 26 additions and 18 deletions

View File

@ -251,10 +251,6 @@ class KeycloakProcessor {
void configureProfile(KeycloakRecorder recorder) {
Profile profile = getCurrentOrCreateFeatureProfile();
if (!Environment.isRebuildCheck()) {
profile.logUnsupportedFeatures();
}
// record the features so that they are not calculated again at runtime
recorder.configureProfile(profile.getName(), profile.getFeatures());
}

View File

@ -135,13 +135,6 @@ public abstract class AbstractAutoBuildCommand extends AbstractCommand {
}
}
/**
* Controls whether the command actually starts the server
*/
protected boolean shouldStart() {
return true;
}
protected void doBeforeRun() {
}
@ -156,4 +149,9 @@ public abstract class AbstractAutoBuildCommand extends AbstractCommand {
return EnumSet.of(OptionCategory.IMPORT, OptionCategory.EXPORT);
}
@Override
public boolean shouldStart() {
return true;
}
}

View File

@ -144,4 +144,11 @@ public abstract class AbstractCommand implements Callable<Integer> {
return false;
}
/**
* Controls whether the command actually starts the server
*/
public boolean shouldStart() {
return false;
}
}

View File

@ -36,7 +36,7 @@ public abstract class AbstractUpdatesCommand extends AbstractAutoBuildCommand {
OptimizedMixin optimizedMixin = new OptimizedMixin();
@Override
protected boolean shouldStart() {
public boolean shouldStart() {
return false;
}

View File

@ -5,6 +5,7 @@ import io.smallrye.config.ConfigValue;
import io.smallrye.config.Expressions;
import jakarta.ws.rs.core.MultivaluedHashMap;
import org.jboss.logging.Logger;
import org.keycloak.common.Profile;
import org.keycloak.common.util.CollectionUtil;
import org.keycloak.config.ConfigSupportLevel;
import org.keycloak.config.Option;
@ -313,6 +314,10 @@ public final class PropertyMappers {
PersistedConfigSource.getInstance().runWithDisabled(Environment::getCurrentOrCreateFeatureProfile);
} else {
Environment.getCurrentOrCreateFeatureProfile();
if (!command.shouldStart()) {
// this will use the deferred logger, which means it may not be seen in some circumstances
Profile.getInstance().logUnsupportedFeatures();
}
}
sanitizeMappers(buildTimeMappers, disabledBuildTimeMappers);

View File

@ -34,7 +34,9 @@ public class FeaturesDistTest {
.filter(feature -> feature.getType() == Profile.Feature.Type.PREVIEW)
.filter(feature -> {
Set<Profile.Feature> versions = Profile.getFeatureVersions(feature.getUnversionedKey());
if (versions.size() == 1) return true;
if (versions.size() == 1) {
return true;
}
return versions.iterator().next().getVersion() == feature.getVersion();
})
.map(Profile.Feature::getVersionedKey)
@ -58,12 +60,12 @@ public class FeaturesDistTest {
assertPreviewFeaturesEnabled(cliResult);
}
// Should enable "fips" together with all other "preview" features
// Should enable "docker" together with all other "preview" features
@Test
@Launch({StartDev.NAME, "--features=preview,fips"})
public void testEnablePreviewFeaturesAndFips(CLIResult cliResult) {
@Launch({StartDev.NAME, "--features=preview,docker"})
public void testEnablePreviewFeaturesAndDocker(CLIResult cliResult) {
cliResult.assertStartedDevMode();
assertPreviewFeaturesEnabled(cliResult);
cliResult.assertError("Failed to configure FIPS.");
}
@Test

View File

@ -59,7 +59,6 @@ public abstract class KeycloakApplication extends Application {
try {
logger.debugv("PlatformProvider: {0}", platform.getClass().getName());
Profile.getInstance().logUnsupportedFeatures();
loadConfig();
platform.onStartup(this::startup);
@ -71,6 +70,7 @@ public abstract class KeycloakApplication extends Application {
}
protected void startup() {
Profile.getInstance().logUnsupportedFeatures();
CryptoIntegration.init(KeycloakApplication.class.getClassLoader());
KeycloakApplication.sessionFactory = createSessionFactory();