Skip to content

Commit

Permalink
[WFCORE-7035]: YAML extension doesn't support ParallelBoot.
Browse files Browse the repository at this point in the history
Adding YAML subsystem operations to the ParallelOperationHandler and
reordering YAML operations to follow the boot operations order.

Jira: https://issues.redhat.com/browse/WFCORE-7035

Signed-off-by: Emmanuel Hugonnet <[email protected]>
  • Loading branch information
ehsavoie committed Oct 28, 2024
1 parent e4bedf5 commit 742b7a4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,9 @@ final boolean isRollingBack() {
@Override
public final void reloadRequired() {
if (processState.isReloadSupported()) {
if(isBooting()) {
return;
}
activeStep.setRestartStamp(processState.setReloadRequired());
activeStep.response.get(RESPONSE_HEADERS, OPERATION_REQUIRES_RELOAD).set(true);
getManagementModel().getCapabilityRegistry().capabilityReloadRequired(activeStep.address,
Expand All @@ -1237,6 +1240,9 @@ public final void reloadRequired() {

@Override
public final void restartRequired() {
if (isBooting()) {
return;
}
activeStep.setRestartStamp(processState.setRestartRequired());
activeStep.response.get(RESPONSE_HEADERS, OPERATION_REQUIRES_RESTART).set(true);
getManagementModel().getCapabilityRegistry().capabilityRestartRequired(activeStep.address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.jboss.as.controller.MapAttributeDefinition;
import org.jboss.as.controller.ObjectMapAttributeDefinition;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.ParallelBootOperationStepHandler;
import org.jboss.as.controller.ParsedBootOp;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.RunningMode;
Expand Down Expand Up @@ -160,13 +161,24 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist
}
MGMT_OP_LOGGER.debug("We are applying YAML files to the configuration");
Map<PathAddress, ParsedBootOp> xmlOperations = new HashMap<>();
ParsedBootOp parallelBootOp = null;
for (ParsedBootOp op : postExtensionOps) {
if (op.getChildOperations().isEmpty()) {
List<ModelNode> childOperations = op.getChildOperations();
if (childOperations.isEmpty()) {
xmlOperations.put(op.getAddress(), op);
} else {
for (ModelNode childOp : op.getChildOperations()) {
ParsedBootOp subOp = new ParsedBootOp(childOp, null);
xmlOperations.put(subOp.getAddress(), subOp);
if (op.handler instanceof ParallelBootOperationStepHandler) {
parallelBootOp = new ParsedBootOp(op, op.handler);
for (ModelNode childOp : childOperations) {
ParsedBootOp subOp = new ParsedBootOp(childOp, null);
xmlOperations.put(subOp.getAddress(), subOp);
parallelBootOp.addChildOperation(subOp);
}
} else {
for (ModelNode childOp : childOperations) {
ParsedBootOp subOp = new ParsedBootOp(childOp, null);
xmlOperations.put(subOp.getAddress(), subOp);
}
}
}
}
Expand All @@ -176,6 +188,18 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist
for (Map.Entry<String, Object> deployment : deployments.entrySet()) {
processUnmanagedDeployments(rootRegistration, deployment, xmlOperations, postExtensionOps);
}
List<ParsedBootOp> reorderedList = new ArrayList<>(postExtensionOps.size());
for (ParsedBootOp op : postExtensionOps) {
if (parallelBootOp != null && op.getAddress().size() > 0 && "subsystem".equals(op.getAddress().getElement(0).getKey())) {
parallelBootOp.addChildOperation(op);
} else if (op.handler instanceof ParallelBootOperationStepHandler) {
reorderedList.add(parallelBootOp);
} else {
reorderedList.add(op);
}
}
postExtensionOps.clear();
postExtensionOps.addAll(reorderedList);
this.configs.clear();
needReload = true;
}
Expand Down Expand Up @@ -424,7 +448,7 @@ private void processAttributes(PathAddress address, ImmutableManagementResourceR
}
}
for (AttributeDefinition def : operationEntry.getOperationDefinition().getParameters()) {
if (def != null && ! attributeNames.contains(def.getName())) {
if (def != null && !attributeNames.contains(def.getName())) {
if (!def.isResourceOnly()) {
attributes.add(def);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ public void testYamlOperations() throws Exception {
result = Operations.readResult(client.execute(Operations.createReadResourceOperation(PathAddress.pathAddress("subsystem", "elytron").toModelNode(), true)));
Assert.assertEquals("Yaml operation to undefine disallowed-providers was not executed.", "undefined", result.get("disallowed-providers").asString());
ModelNode permissions = result.get("permission-set").get("default-permissions").get("permissions");
Assert.assertEquals("Yaml change to port set mail-smtp outbound socket binding is wrong", "[{\"class-name\" => \"org.wildfly.security.auth.permission.LoginPermission\",\"module\" => \"org.wildfly.security.elytron-base\",\"target-name\" => \"*\"}]", permissions.asString());
Assert.assertEquals("Yaml change to set default permissions is wrong", "[{\"class-name\" => \"org.wildfly.security.auth.permission.LoginPermission\",\"module\" => \"org.wildfly.security.elytron-base\",\"target-name\" => \"*\"}]", permissions.asString());
}

@Test
Expand Down

0 comments on commit 742b7a4

Please sign in to comment.