Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFCORE-6843] Logging a WARN if a deployment's runtime name doesn't have an extension #6340

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public interface DomainControllerLogger extends BasicLogger {
*/
DomainControllerLogger HOST_CONTROLLER_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), DomainControllerLogger.class, "org.jboss.as.host.controller");

/**
* A logger with the category of {@code org.jboss.as.domain.controller.operations.deployment.runtime.namecheck}.
* <strong>Usage:</strong> Use this in case deployment's runtime name is missing an extension
*/
DomainControllerLogger DEPLOYMENT_NAMECHECK_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), DomainControllerLogger.class, "org.jboss.as.domain.controller.operations.deployment.runtime.namecheck");

@LogMessage(level = Level.WARN)
@Message(id = 1, value = "Ignoring 'include' child of 'socket-binding-group' %s")
void warnIgnoringSocketBindingGroupInclude(Location location);
Expand Down Expand Up @@ -789,4 +795,8 @@ public interface DomainControllerLogger extends BasicLogger {

@Message(id = 98, value = "The following servers %s are starting; execution of remote management operations is not currently available")
OperationFailedException serverManagementUnavailableDuringBoot(String serverNames);

@LogMessage(level = Level.WARN)
@Message(id = 99, value = "Deployment '%s' has a runtime name '%s' without an extension. This may cause issues in some environments.")
void deploymentsRuntimeNameWithoutExtension(String deploymentName, String runtimeName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CONTENT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DEPLOYMENT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.domain.controller.logging.DomainControllerLogger.DEPLOYMENT_NAMECHECK_LOGGER;
import static org.jboss.as.server.controller.resources.DeploymentAttributes.CONTENT_HASH;
import static org.jboss.as.server.controller.resources.DeploymentAttributes.ENABLED;
import static org.jboss.as.server.controller.resources.DeploymentAttributes.RUNTIME_NAME_NILLABLE;
Expand Down Expand Up @@ -94,6 +95,9 @@ static void validateRuntimeNames(String deploymentName, OperationContext context
Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
ModelNode domainDeployment = root.getChild(PathElement.pathElement(DEPLOYMENT, deploymentName)).getModel();
String runtimeName = getRuntimeName(deploymentName, deployment, domainDeployment);
if (!runtimeName.contains(".")) {
DEPLOYMENT_NAMECHECK_LOGGER.deploymentsRuntimeNameWithoutExtension(deploymentName, runtimeName);
}
PathAddress sgAddress = address.subAddress(0, address.size() - 1);
Resource serverGroup = root.navigate(sgAddress);
for (Resource.ResourceEntry re : serverGroup.getChildren(DEPLOYMENT)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.jboss.as.server.controller.resources.DeploymentAttributes.PERSISTENT;
import static org.jboss.as.server.deployment.DeploymentHandlerUtils.getContents;
import static org.jboss.as.server.deployment.DeploymentHandlerUtils.getInputStream;
import static org.jboss.as.server.logging.ServerLogger.DEPLOYMENT_NAMECHECK_LOGGER;
import static org.jboss.msc.service.ServiceController.Mode.REMOVE;

import java.io.IOException;
Expand Down Expand Up @@ -142,6 +143,9 @@ public static void deploy(final OperationContext context, final ModelNode operat

context.addStep(new OperationStepHandler() {
public void execute(OperationContext context, ModelNode operation) {
if (!deploymentUnitName.contains(".")) {
DEPLOYMENT_NAMECHECK_LOGGER.deploymentsRuntimeNameWithoutExtension(managementName, deploymentUnitName);
}
Comment on lines +146 to +148
Copy link
Collaborator

@yersan yersan Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last detail, we need to do the same for the other methods as redeploy, replace

The same applies to Domain Mode handlers, we need to cover the redeploy and replace

final ServiceName deploymentUnitServiceName = Services.deploymentUnitName(deploymentUnitName);
final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
final ServiceController<?> deploymentController = serviceRegistry.getService(deploymentUnitServiceName);
Expand Down
10 changes: 10 additions & 0 deletions server/src/main/java/org/jboss/as/server/logging/ServerLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public interface ServerLogger extends BasicLogger {
*/
ServerLogger DEPRECATED_DEP_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), ServerLogger.class, "org.jboss.as.dependency.deprecated");

/**
* A logger with the category of {@code org.jboss.as.server.deployment.runtime.namecheck}.
* <strong>Usage:</strong> Use this in case deployment's runtime name is missing an extension
*/
ServerLogger DEPLOYMENT_NAMECHECK_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), ServerLogger.class, "org.jboss.as.server.deployment.runtime.namecheck");

/**
* Log message for when a jboss-deployment-structure.xml file is ignored
* @param file name of the ignored file
Expand Down Expand Up @@ -1481,6 +1487,10 @@ default void suspendingServer(long timeout, TimeUnit unit) {
@Message(id = 311, value = "Cannot create a ServerEnvironment for an embedded server")
IllegalStateException cannotCreateServerEnvironment();

@LogMessage(level = Logger.Level.WARN)
@Message(id = 312, value = "Deployment '%s' has a runtime name '%s' without an extension. This may cause issues in some environments.")
void deploymentsRuntimeNameWithoutExtension(String managementName, String deploymentUnitName);

////////////////////////////////////////////////
//Messages without IDs

Expand Down
Loading