From c7c641b3ee53e5a8fb2a36b75f6c21f3813f631e Mon Sep 17 00:00:00 2001 From: Eduardo Martins Date: Tue, 14 May 2024 16:02:35 +0100 Subject: [PATCH] [CMTOOL-368] only adds subsystem configs to leaf profiles --- .../subsystem/AddSubsystemResourceSubtaskBuilder.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/servers/wildfly10.0/src/main/java/org/jboss/migration/wfly10/config/task/management/subsystem/AddSubsystemResourceSubtaskBuilder.java b/servers/wildfly10.0/src/main/java/org/jboss/migration/wfly10/config/task/management/subsystem/AddSubsystemResourceSubtaskBuilder.java index 9ad3102b2..8a77ad694 100644 --- a/servers/wildfly10.0/src/main/java/org/jboss/migration/wfly10/config/task/management/subsystem/AddSubsystemResourceSubtaskBuilder.java +++ b/servers/wildfly10.0/src/main/java/org/jboss/migration/wfly10/config/task/management/subsystem/AddSubsystemResourceSubtaskBuilder.java @@ -21,6 +21,7 @@ import org.jboss.migration.core.task.ServerMigrationTaskName; import org.jboss.migration.core.task.ServerMigrationTaskResult; import org.jboss.migration.core.task.TaskContext; +import org.jboss.migration.wfly10.config.management.ProfileResource; import org.jboss.migration.wfly10.config.management.SubsystemResource; import org.jboss.migration.wfly10.config.task.management.resource.ManageableResourceBuildParameters; import org.jboss.migration.wfly10.config.task.management.resource.ManageableResourceLeafTask; @@ -38,10 +39,19 @@ public AddSubsystemResourceSubtaskBuilder(String subsystem) { nameBuilder(parameters -> new ServerMigrationTaskName.Builder("subsystem."+subsystem+".add-config").addAttribute("name", parameters.getResource().getResourceAbsoluteName()).build()); runBuilder(params -> taskContext -> { SubsystemResource.Parent parent = params.getResource(); + // skip if subsystem already exists in current "profile" if (parent.hasSubsystemResource(subsystem)) { taskContext.getLogger().debugf("Skipped adding subsystem config %s, already exists.", parent.getSubsystemResourceAbsoluteName(subsystem)); return ServerMigrationTaskResult.SKIPPED; } + // skip if parent is a profile that includes another profile, we only add configurations to leaf profiles (prevents CMTOOL-368) + if (parent.getResourceType() == ProfileResource.RESOURCE_TYPE) { + final String includes = parent.getResourceConfiguration().get("includes").asStringOrNull(); + if (includes != null) { + taskContext.getLogger().warnf("Subsystem to be added on profile %s, which includes profile(s) %s, skipping...", parent.getResourceName(), includes); + return ServerMigrationTaskResult.SKIPPED; + } + } final String configName = parent.getSubsystemResourceAbsoluteName(subsystem); taskContext.getLogger().debugf("Adding subsystem config %s...", configName); addConfiguration(params, taskContext);