Skip to content

Commit

Permalink
[WFCORE-7011] Use 'default' stability level when the remote host cont…
Browse files Browse the repository at this point in the history
…roller do not advertise its current stability level

Jira issue: https://issues.redhat.com/browse/WFCORE-7011
  • Loading branch information
yersan committed Nov 27, 2024
1 parent 5691397 commit eeec122
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 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 @@ -150,7 +150,7 @@ public ProductConfig(final String productName, final String productVersion, fina
this.name = productName;
this.version = productVersion;
this.consoleSlot = consoleSlot;
this.defaultStability = Stability.DEFAULT;
this.defaultStability = Stability.COMMUNITY;
this.stabilities = EnumSet.of(this.defaultStability);
this.banner = null;
}
Expand Down

0 comments on commit eeec122

Please sign in to comment.