Skip to content

Commit

Permalink
[WFCORE-7076] Check required installation metadata is present before …
Browse files Browse the repository at this point in the history
…registering installation-manager subsystem
  • Loading branch information
spyrkob committed Nov 29, 2024
1 parent e4347c2 commit c13f1ee
Show file tree
Hide file tree
Showing 21 changed files with 304 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ private static int getBootStackSize() {
private final CapabilityRegistry capabilityRegistry;
private final ConfigurationExtension configExtension;
private volatile ModelControllerClientFactory clientFactory;
protected final Supplier<PathManager> pathManagerSupplier;

/**
* Construct a new instance.
Expand All @@ -200,7 +201,7 @@ protected AbstractControllerService(final ProcessType processType, final Running
final ManagedAuditLogger auditLogger, final DelegatingConfigurableAuthorizer authorizer,
final ManagementSecurityIdentitySupplier securityIdentitySupplier, final CapabilityRegistry capabilityRegistry) {
this(null, null, processType, Stability.DEFAULT, runningModeControl, configurationPersister, processState, rootResourceDefinition, null,
prepareStep, expressionResolver, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, null);
prepareStep, expressionResolver, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, null, null);
}

/**
Expand Down Expand Up @@ -229,7 +230,7 @@ protected AbstractControllerService(final Supplier<ExecutorService> executorServ
final ManagementSecurityIdentitySupplier securityIdentitySupplier,
final CapabilityRegistry capabilityRegistry, final ConfigurationExtension configExtension) {
this(executorService, instabilityListener, processType, Stability.DEFAULT, runningModeControl, configurationPersister, processState, rootResourceDefinition, null,
prepareStep, expressionResolver, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, configExtension);
prepareStep, expressionResolver, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, configExtension, null);
}

/**
Expand All @@ -247,6 +248,7 @@ protected AbstractControllerService(final Supplier<ExecutorService> executorServ
* @param authorizer handles authorization
* @param capabilityRegistry the capability registry
*/
@Deprecated
protected AbstractControllerService(final Supplier<ExecutorService> executorService,
final Supplier<ControllerInstabilityListener> instabilityListener,
final ProcessType processType, Stability stability, final RunningModeControl runningModeControl,
Expand All @@ -257,7 +259,36 @@ protected AbstractControllerService(final Supplier<ExecutorService> executorServ
final ManagementSecurityIdentitySupplier securityIdentitySupplier,
final CapabilityRegistry capabilityRegistry, final ConfigurationExtension configExtension) {
this(executorService, instabilityListener, processType, stability, runningModeControl, configurationPersister, processState, rootResourceDefinition, null,
prepareStep, expressionResolver, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, configExtension);
prepareStep, expressionResolver, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, configExtension, null);
}

/**
* Construct a new instance.
*
* @param processType the type of process being controlled
* @param stability the stability level of the controlled process
* @param runningModeControl the controller of the process' running mode
* @param configurationPersister the configuration persister
* @param processState the controlled process state
* @param rootResourceDefinition the root resource definition
* @param prepareStep the prepare step to prepend to operation execution
* @param expressionResolver the expression resolver
* @param auditLogger the audit logger
* @param authorizer handles authorization
* @param capabilityRegistry the capability registry
*/
protected AbstractControllerService(final Supplier<ExecutorService> executorService,
final Supplier<ControllerInstabilityListener> instabilityListener,
final ProcessType processType, Stability stability, final RunningModeControl runningModeControl,
final ConfigurationPersister configurationPersister,
final ControlledProcessState processState, final ResourceDefinition rootResourceDefinition,
final OperationStepHandler prepareStep, final ExpressionResolver expressionResolver,
final ManagedAuditLogger auditLogger, final DelegatingConfigurableAuthorizer authorizer,
final ManagementSecurityIdentitySupplier securityIdentitySupplier,
final CapabilityRegistry capabilityRegistry, final ConfigurationExtension configExtension,
final Supplier<PathManager> pathManagerSupplier) {
this(executorService, instabilityListener, processType, stability, runningModeControl, configurationPersister, processState, rootResourceDefinition, null,
prepareStep, expressionResolver, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, configExtension, pathManagerSupplier);
}

private AbstractControllerService(final Supplier<ExecutorService> executorService,
Expand All @@ -267,7 +298,8 @@ private AbstractControllerService(final Supplier<ExecutorService> executorServic
final ResourceDefinition rootResourceDefinition, final DescriptionProvider rootDescriptionProvider,
final OperationStepHandler prepareStep, final ExpressionResolver expressionResolver, final ManagedAuditLogger auditLogger,
final DelegatingConfigurableAuthorizer authorizer, final ManagementSecurityIdentitySupplier securityIdentitySupplier,
final CapabilityRegistry capabilityRegistry, final ConfigurationExtension configExtension) {
final CapabilityRegistry capabilityRegistry, final ConfigurationExtension configExtension,
final Supplier<PathManager> pathManagerSupplier) {
assert rootDescriptionProvider == null : "description provider cannot be used anymore";
assert rootResourceDefinition != null : "Null root resource definition";
assert expressionResolver != null : "Null expressionResolver";
Expand All @@ -276,6 +308,7 @@ private AbstractControllerService(final Supplier<ExecutorService> executorServic
assert securityIdentitySupplier != null : "Null securityIdentitySupplier";
assert capabilityRegistry != null : "Null capabilityRegistry";
assert stability != null : "Null stability";
assert pathManagerSupplier != null;
this.executorService = executorService;
this.instabilityListener = instabilityListener;
this.processType = processType;
Expand All @@ -292,6 +325,7 @@ private AbstractControllerService(final Supplier<ExecutorService> executorServic
this.bootErrorCollector = new BootErrorCollector();
this.capabilityRegistry = capabilityRegistry.createShadowCopy(); //create shadow copy of proper registry so changes can only be visible by .publish()
this.configExtension = configExtension;
this.pathManagerSupplier = pathManagerSupplier;
}

@Override
Expand Down Expand Up @@ -698,10 +732,10 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
assert !processType.isHostController() || hostName != null;
for (ModelControllerServiceInitialization init : sl) {
if (processType.isHostController()) {
init.initializeHost(context.getServiceTarget(), managementModel, hostName, processType);
init.initializeHost(context.getServiceTarget(), managementModel, hostName, processType, pathManagerSupplier.get());
init.initializeDomain(context.getServiceTarget(), managementModel);
} else {
init.initializeStandalone(context.getServiceTarget(), managementModel, processType);
init.initializeStandalone(context.getServiceTarget(), managementModel, processType, pathManagerSupplier.get());

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.jboss.as.controller;

import org.jboss.as.controller.services.path.PathManager;
import org.jboss.msc.service.ServiceTarget;

/**
Expand All @@ -20,8 +21,9 @@ public interface ModelControllerServiceInitialization {
* @param target the service target
* @param managementModel the management model
* @param processType The ProcessType used to identify what type of server we are running in.
* @param pathManager The PathManager for the running server
*/
void initializeStandalone(ServiceTarget target, ManagementModel managementModel, ProcessType processType);
void initializeStandalone(ServiceTarget target, ManagementModel managementModel, ProcessType processType, PathManager pathManager);

/**
* Initialize the domain controller.
Expand All @@ -37,7 +39,8 @@ public interface ModelControllerServiceInitialization {
* @param managementModel the management model
* @param hostName the name of the host
* @param processType The ProcessType that to identify what type of server we are running in.
* @param pathManager The PathManager for the running server
*/
void initializeHost(ServiceTarget target, ManagementModel managementModel, String hostName, ProcessType processType);
void initializeHost(ServiceTarget target, ManagementModel managementModel, String hostName, ProcessType processType, PathManager pathManager);

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.jboss.as.controller.persistence.ConfigurationExtension;
import org.jboss.as.controller.persistence.ConfigurationPersister;
import org.jboss.as.controller.persistence.NullConfigurationPersister;
import org.jboss.as.controller.services.path.PathManager;
import org.jboss.as.controller.services.path.PathManagerService;
import org.jboss.as.version.Stability;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
Expand All @@ -31,6 +33,8 @@
*/
public abstract class TestModelControllerService extends AbstractControllerService {

protected static final Supplier<PathManager> DEFAULT_PATH_MANAGER = () -> new PathManagerService() {
};
private final ControlledProcessState processState;
final AtomicBoolean state = new AtomicBoolean(true);
private final CountDownLatch latch = new CountDownLatch(2);
Expand Down Expand Up @@ -74,7 +78,7 @@ protected TestModelControllerService(final ProcessType processType, final Runnin
final ConfigurationPersister configurationPersister, final ControlledProcessState processState,
final ResourceDefinition rootResourceDefinition, final CapabilityRegistry capabilityRegistry, final ConfigurationExtension configExtension) {
super(executorService, null, processType, Stability.DEFAULT, runningModeControl, configurationPersister, processState, rootResourceDefinition, null, ExpressionResolver.TEST_RESOLVER,
AuditLogger.NO_OP_LOGGER, new DelegatingConfigurableAuthorizer(), new ManagementSecurityIdentitySupplier(), capabilityRegistry, configExtension);
AuditLogger.NO_OP_LOGGER, new DelegatingConfigurableAuthorizer(), new ManagementSecurityIdentitySupplier(), capabilityRegistry, configExtension, DEFAULT_PATH_MANAGER);
this.processState = processState;
this.capabilityRegistry = capabilityRegistry;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.jboss.as.controller.audit.AuditLogger;
import org.jboss.as.controller.descriptions.NonResolvingResourceDescriptionResolver;
import org.jboss.as.controller.persistence.ConfigurationPersister;
import org.jboss.as.controller.services.path.PathManager;
import org.jboss.as.controller.services.path.PathManagerService;
import org.jboss.as.version.Stability;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
Expand All @@ -35,6 +37,8 @@
* @author <a href="mailto:[email protected]">Yeray Borges</a>
*/
public abstract class TestModelControllerService extends AbstractControllerService {
protected static final Supplier<PathManager> DEFAULT_PATH_MANAGER = () -> new PathManagerService() {
};
private final CountDownLatch latch = new CountDownLatch(2);
private final CapabilityRegistry capabilityRegistry;

Expand All @@ -56,7 +60,7 @@ protected TestModelControllerService(final ProcessType processType, Stability st
final ConfigurationPersister configurationPersister, final ControlledProcessState processState,
final ResourceDefinition rootResourceDefinition, final CapabilityRegistry capabilityRegistry) {
super(executorService, null, processType, stability, runningModeControl, configurationPersister, processState, rootResourceDefinition, null, ExpressionResolver.TEST_RESOLVER,
AuditLogger.NO_OP_LOGGER, new DelegatingConfigurableAuthorizer(), new ManagementSecurityIdentitySupplier(), capabilityRegistry, null);
AuditLogger.NO_OP_LOGGER, new DelegatingConfigurableAuthorizer(), new ManagementSecurityIdentitySupplier(), capabilityRegistry, null, DEFAULT_PATH_MANAGER);
this.capabilityRegistry = capabilityRegistry;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
import org.jboss.as.controller.registry.ResourceProvider;
import org.jboss.as.controller.remote.AbstractModelControllerOperationHandlerFactoryService;
import org.jboss.as.controller.remote.ModelControllerOperationHandlerFactory;
import org.jboss.as.controller.services.path.PathManager;
import org.jboss.as.controller.services.path.PathManagerService;
import org.jboss.as.controller.transform.Transformers;
import org.jboss.as.domain.controller.DomainController;
Expand Down Expand Up @@ -287,13 +288,14 @@ static void addService(final ServiceTarget serviceTarget,

final ServiceBuilder<?> sb = serviceTarget.addService(SERVICE_NAME);
final Supplier<ExecutorService> esSupplier = sb.requires(HC_EXECUTOR_SERVICE_NAME);
final Supplier<PathManager> pathManagerSupplier = sb.requires(PATH_MANAGER_CAPABILITY.getCapabilityServiceName());
final DomainModelControllerService service = new DomainModelControllerService(esSupplier, environment, runningModeControl, processState,
hostControllerInfo, contentRepository, hostProxies, serverProxies, prepareStepHandler,
ignoredRegistry, bootstrapListener, pathManager, expressionResolver, new DomainDelegatingResourceDefinition(),
hostExtensionRegistry, extensionRegistry, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, domainHostExcludeRegistry);
hostExtensionRegistry, extensionRegistry, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, domainHostExcludeRegistry,
pathManagerSupplier);
sb.setInstance(service);
sb.addDependency(ProcessControllerConnectionService.SERVICE_NAME, ProcessControllerConnectionService.class, service.injectedProcessControllerConnection);
sb.requires(PATH_MANAGER_CAPABILITY.getCapabilityServiceName()); // ensure this is up
service.consoleAvailabilitySupplier = sb.requires(CONSOLE_AVAILABILITY_CAPABILITY.getCapabilityServiceName());
sb.install();

Expand Down Expand Up @@ -321,9 +323,10 @@ private DomainModelControllerService(final Supplier<ExecutorService> executorSer
final DelegatingConfigurableAuthorizer authorizer,
final ManagementSecurityIdentitySupplier securityIdentitySupplier,
final CapabilityRegistry capabilityRegistry,
final DomainHostExcludeRegistry domainHostExcludeRegistry) {
final DomainHostExcludeRegistry domainHostExcludeRegistry,
final Supplier<PathManager> pathManagerSupplier) {
super(executorService, null, environment.getProcessType(), environment.getStability(), runningModeControl, null, processState,
rootResourceDefinition, prepareStepHandler, expressionResolver, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, null);
rootResourceDefinition, prepareStepHandler, expressionResolver, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, null, pathManagerSupplier);
this.environment = environment;
this.runningModeControl = runningModeControl;
this.processState = processState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
import org.jboss.as.controller.persistence.ConfigurationPersister;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.controller.services.path.PathManagerService;
import org.jboss.as.domain.controller.operations.ApplyExtensionsHandler;
import org.jboss.as.host.controller.mgmt.HostControllerRegistrationHandler;
import org.jboss.as.version.Stability;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
Expand All @@ -55,8 +57,10 @@ protected TestModelControllerService(final ProcessType processType, final Config
final ResourceDefinition rootResourceDefinition, final ManagedAuditLogger auditLogger,
final AbstractControllerTestBase.DelegatingResourceDefinitionInitializer initializer,
final CapabilityRegistry capabilityRegistry) {
super(processType, new RunningModeControl(RunningMode.NORMAL), configurationPersister, processState, rootResourceDefinition,
null, ExpressionResolver.TEST_RESOLVER, auditLogger, new DelegatingConfigurableAuthorizer(), new ManagementSecurityIdentitySupplier(), capabilityRegistry);
super(null, null, processType, Stability.DEFAULT, new RunningModeControl(RunningMode.NORMAL),
configurationPersister, processState, rootResourceDefinition, null, ExpressionResolver.TEST_RESOLVER,
auditLogger, new DelegatingConfigurableAuthorizer(), new ManagementSecurityIdentitySupplier(),
capabilityRegistry, null, ()->new PathManagerService() {});
this.processState = processState;
internalExecutor = new InternalExecutor();
this.initializer = initializer;
Expand Down
Loading

0 comments on commit c13f1ee

Please sign in to comment.