Skip to content

Commit

Permalink
Merge pull request #6204 from yersan/WFCORE-7011
Browse files Browse the repository at this point in the history
[WFCORE-7011] Use 'default' stability level when the remote host controller do not advertise its current stability level
  • Loading branch information
yersan authored Nov 29, 2024
2 parents 602934a + 005b659 commit 0a51ca7
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public synchronized void start(StartContext context) throws StartException {
* This value does not require locking during use, as {@link org.jboss.as.host.controller.mgmt.HostInfo createLocalHostHostInfo()} uses
* '/domain-controller', which is read-only, and '/core-service=ignored-resources/ignored-resource-type' which has handlers on
* add, remove and write-attribute that will place the host into reload-required.
* @return
* @return A ModelNode containing the metadata of the local Host Controller
*/
@Override
public ModelNode createLocalHostInfo() {
Expand All @@ -517,7 +517,7 @@ public ModelNode resolveSubsystemVersions(ModelNode extensions) {
@Override
public boolean applyDomainModel(final List<ModelNode> bootOperations) {
// Apply the model..
final HostInfo info = HostInfo.fromModelNode(createLocalHostInfo(), null, productConfig);
final HostInfo info = HostInfo.fromModelNode(createLocalHostInfo(), null);
return applyRemoteDomainModel(bootOperations, info);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ private RegistrationContext(ExtensionRegistry extensionRegistry,

private synchronized void initialize(final String hostName, final ModelNode hostInfo, final ManagementRequestContext<RegistrationContext> responseChannel) {
this.hostName = hostName;
this.hostInfo = HostInfo.fromModelNode(hostInfo, domainHostExcludeRegistry, domainController.getLocalHostInfo().getProductConfig());
this.hostInfo = HostInfo.fromModelNode(hostInfo, domainHostExcludeRegistry);
this.responseChannel = responseChannel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ public static ModelNode createLocalHostHostInfo(final LocalHostControllerInfo ho
return info;
}

public static HostInfo fromModelNode(final ModelNode hostInfo, ProductConfig productConfig) {
return fromModelNode(hostInfo, null, productConfig);
public static HostInfo fromModelNode(final ModelNode hostInfo) {
return fromModelNode(hostInfo, null);
}

public static HostInfo fromModelNode(final ModelNode hostInfo, DomainHostExcludeRegistry hostIgnoreRegistry, ProductConfig productConfig) {
return new HostInfo(hostInfo, hostIgnoreRegistry, productConfig);
public static HostInfo fromModelNode(final ModelNode hostInfo, DomainHostExcludeRegistry hostIgnoreRegistry) {
return new HostInfo(hostInfo, hostIgnoreRegistry);
}

private final String hostName;
Expand All @@ -122,7 +122,7 @@ public static HostInfo fromModelNode(final ModelNode hostInfo, DomainHostExclude
// GuardedBy this
private ReadMasterDomainModelUtil.RequiredConfigurationHolder requiredConfigurationHolder;

private HostInfo(final ModelNode hostInfo, DomainHostExcludeRegistry hostIgnoreRegistry, ProductConfig productConfig) {
private HostInfo(final ModelNode hostInfo, DomainHostExcludeRegistry hostIgnoreRegistry) {
hostName = hostInfo.require(NAME).asString();
releaseVersion = hostInfo.require(RELEASE_VERSION).asString();
releaseCodeName = hostInfo.require(RELEASE_CODENAME).asString();
Expand All @@ -134,7 +134,7 @@ private HostInfo(final ModelNode hostInfo, DomainHostExcludeRegistry hostIgnoreR
remoteConnectionId = hostInfo.hasDefined(RemoteDomainConnectionService.DOMAIN_CONNECTION_ID)
? hostInfo.get(RemoteDomainConnectionService.DOMAIN_CONNECTION_ID).asLong() : null;
// Legacy hosts may return null - if so, assume default stability per our ProductConfig
this.stability = Optional.ofNullable(hostInfo.get(ModelDescriptionConstants.STABILITY).asStringOrNull()).map(Stability::valueOf).orElse(productConfig.getDefaultStability());
this.stability = Optional.ofNullable(hostInfo.get(ModelDescriptionConstants.STABILITY).asStringOrNull()).map(Stability::valueOf).orElse(Stability.DEFAULT);

Set<String> domainIgnoredExtensions = null;
Set<String> domainActiveServerGroups = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PROFILE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELEASE_CODENAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELEASE_VERSION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STABILITY;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WILDCARD;

import java.util.Collections;
Expand Down Expand Up @@ -74,7 +75,7 @@ public void testResourceTransformation() throws Exception {
Assert.assertEquals("value", original.get("profile", "not-ignored", "subsystem", "thingy", "attr").asString());
Assert.assertEquals("value", original.get("profile", "ignored", "subsystem", "thingy", "attr").asString());


ProductConfig productConfig = new ProductConfig("name", "version", "slot");
ModelNode hostInfo = new ModelNode();
hostInfo.get(NAME).set("kabirs-macbook-pro.local");
hostInfo.get(RELEASE_VERSION).set("8.0.0.Alpha1-SNAPSHOT");
Expand All @@ -88,9 +89,10 @@ public void testResourceTransformation() throws Exception {
hostInfo.get(IGNORED_RESOURCES, EXTENSION, NAMES).add("ignored");
hostInfo.get(IGNORE_UNUSED_CONFIG).set(false);
hostInfo.get(INITIAL_SERVER_GROUPS).setEmptyObject();
hostInfo.get(STABILITY).set(productConfig.getDefaultStability().name());
hostInfo.get("domain-connection-id").set(1361470170404L);

Resource transformedResource = transformResource(registry, resourceRoot, resourceRegistration, HostInfo.fromModelNode(hostInfo, new ProductConfig("name", "version", "slot")));
Resource transformedResource = transformResource(registry, resourceRoot, resourceRegistration, HostInfo.fromModelNode(hostInfo));
ModelNode transformed = Resource.Tools.readModel(transformedResource);

Assert.assertEquals("value", transformed.get("extension", "not-ignored", "attr").asString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
HostInfo.createLocalHostHostInfo(hostControllerInfo,
cfg,
ignoredDomainResourceRegistry,
hostResource), cfg);
hostResource));
final SyncDomainModelOperationHandler handler =
new SyncDomainModelOperationHandler(hostInfo, parameters);
context.addStep(syncOperation, handler, OperationContext.Stage.MODEL, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testBasicInfo() {
Assert.assertEquals(new ModelNode().setEmptyObject(), model.get(INITIAL_SERVER_GROUPS));


HostInfo testee = HostInfo.fromModelNode(model, productConfig);
HostInfo testee = HostInfo.fromModelNode(model);
Assert.assertEquals("test", testee.getHostName());
Assert.assertEquals("product", testee.getProductName());
Assert.assertEquals("version", testee.getProductVersion());
Expand All @@ -61,7 +61,7 @@ public void testBasicInfo() {
productConfig = new ProductConfig(null, null, "main");
model = HostInfo.createLocalHostHostInfo(lch, productConfig, ignoredRegistry, Resource.Factory.create());
model.get(RemoteDomainConnectionService.DOMAIN_CONNECTION_ID).set(1L);
testee = HostInfo.fromModelNode(model, productConfig);
testee = HostInfo.fromModelNode(model);
Assert.assertNull(testee.getProductName());
Assert.assertNull(testee.getProductVersion());
Assert.assertNotNull(testee.getRemoteConnectionId());
Expand Down Expand Up @@ -132,7 +132,7 @@ public void testIgnoredResources() {

ModelNode model = HostInfo.createLocalHostHostInfo(lch, productConfig, ignoredRegistry, Resource.Factory.create());

HostInfo testee = HostInfo.fromModelNode(model, productConfig);
HostInfo testee = HostInfo.fromModelNode(model);

Assert.assertTrue(testee.isResourceTransformationIgnored(PathAddress.pathAddress(PathElement.pathElement("wildcard", "ignored"))));
Assert.assertTrue(testee.isResourceTransformationIgnored(PathAddress.pathAddress(PathElement.pathElement("list", "ignored"))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.jboss.as.server.ServerEnvironment.HOME_DIR;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.jboss.as.server.ServerEnvironment.HOME_DIR;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

Expand All @@ -22,6 +21,7 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
import java.util.Properties;

import org.jboss.as.controller.RunningMode;
import org.jboss.as.controller.persistence.ConfigurationFile;
import org.jboss.as.version.ProductConfig;
Expand Down Expand Up @@ -131,7 +131,7 @@ public void testAliasNotWorkingInDefaultStability() throws IOException {

// default stability = DEFAULT
ProductConfig productConfig = new ProductConfig(null, null, null);
assertEquals(Stability.DEFAULT, productConfig.getDefaultStability());
Assume.assumeTrue(Stability.DEFAULT.equals(productConfig.getDefaultStability()));

Exception exception = assertThrows(IllegalStateException.class, () -> {
createServerEnvironment(props, "lb", productConfig);
Expand Down
7 changes: 5 additions & 2 deletions version/src/main/java/org/jboss/as/version/ProductConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Properties;
import java.util.Set;
import java.util.jar.Manifest;
import java.util.stream.Collectors;

import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
Expand Down Expand Up @@ -150,8 +151,10 @@ public ProductConfig(final String productName, final String productVersion, fina
this.name = productName;
this.version = productVersion;
this.consoleSlot = consoleSlot;
this.defaultStability = Stability.DEFAULT;
this.stabilities = EnumSet.of(this.defaultStability);
this.defaultStability = Stability.COMMUNITY;
this.stabilities = EnumSet.allOf(Stability.class).stream()
.filter(this.defaultStability::enables)
.collect(Collectors.toUnmodifiableSet());
this.banner = null;
}

Expand Down

0 comments on commit 0a51ca7

Please sign in to comment.