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.

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

Signed-off-by: Emmanuel Hugonnet <[email protected]>
  • Loading branch information
ehsavoie committed Dec 9, 2024
1 parent 435779c commit 41b3b80
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
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,29 @@ 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) {
/* We need to createa new ParsedBootOp so that the handler number of childOperations is different from the number of childOperation of the handler and thus the handler will be properly updated.
* @see ModelCOntrollerImpl.boot(final List<ModelNode> bootList, final OperationMessageHandler handler, final OperationTransactionControl control,
* final boolean rollbackOnRuntimeFailure, MutableRootResourceRegistrationProvider parallelBootRootResourceRegistrationProvider,
* final boolean skipModelValidation, final boolean partialModel, final ConfigurationExtension configExtension)
*/
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 +193,21 @@ 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())) {
//The new operations created from the YAML are added to the parallel boot operation enclosing all the subsystem operations
parallelBootOp.addChildOperation(op);
} else if (op.handler instanceof ParallelBootOperationStepHandler) {
//The parallel boot operation is added to the list
reorderedList.add(parallelBootOp);
} else {
//The new operations created from the YAML are added to the list of operations (if they haven't already be added in a subsystem enclosing operation).
reorderedList.add(op);
}
}
postExtensionOps.clear();
postExtensionOps.addAll(reorderedList);
this.configs.clear();
needReload = true;
}
Expand Down Expand Up @@ -424,7 +456,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 41b3b80

Please sign in to comment.