From 742b7a46bd74351e9afe50f4e46f2559906609ea Mon Sep 17 00:00:00 2001 From: Emmanuel Hugonnet Date: Mon, 28 Oct 2024 12:52:22 +0100 Subject: [PATCH] [WFCORE-7035]: YAML extension doesn't support ParallelBoot. 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 --- .../controller/AbstractOperationContext.java | 6 ++++ .../yaml/YamlConfigurationExtension.java | 34 ++++++++++++++++--- .../yaml/YamlExtensionTestCase.java | 2 +- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/controller/src/main/java/org/jboss/as/controller/AbstractOperationContext.java b/controller/src/main/java/org/jboss/as/controller/AbstractOperationContext.java index bccddea4f96..28c5473740f 100644 --- a/controller/src/main/java/org/jboss/as/controller/AbstractOperationContext.java +++ b/controller/src/main/java/org/jboss/as/controller/AbstractOperationContext.java @@ -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, @@ -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, diff --git a/controller/src/main/java/org/jboss/as/controller/persistence/yaml/YamlConfigurationExtension.java b/controller/src/main/java/org/jboss/as/controller/persistence/yaml/YamlConfigurationExtension.java index f243173ba33..52aeb092749 100644 --- a/controller/src/main/java/org/jboss/as/controller/persistence/yaml/YamlConfigurationExtension.java +++ b/controller/src/main/java/org/jboss/as/controller/persistence/yaml/YamlConfigurationExtension.java @@ -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; @@ -160,13 +161,24 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist } MGMT_OP_LOGGER.debug("We are applying YAML files to the configuration"); Map xmlOperations = new HashMap<>(); + ParsedBootOp parallelBootOp = null; for (ParsedBootOp op : postExtensionOps) { - if (op.getChildOperations().isEmpty()) { + List 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); + } } } } @@ -176,6 +188,18 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist for (Map.Entry deployment : deployments.entrySet()) { processUnmanagedDeployments(rootRegistration, deployment, xmlOperations, postExtensionOps); } + List 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; } @@ -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); } diff --git a/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/management/persistence/yaml/YamlExtensionTestCase.java b/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/management/persistence/yaml/YamlExtensionTestCase.java index 00c33932546..8e4901b272e 100644 --- a/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/management/persistence/yaml/YamlExtensionTestCase.java +++ b/testsuite/manualmode/src/test/java/org/jboss/as/test/manualmode/management/persistence/yaml/YamlExtensionTestCase.java @@ -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