Skip to content

Commit

Permalink
Merge pull request #6901 from breakponchito/FISH-9502-fix-untargeted-…
Browse files Browse the repository at this point in the history
…app-deployment-instance

FISH-9502: adding validation to skip deploy on target
  • Loading branch information
breakponchito authored Aug 29, 2024
2 parents 2f7e3d9 + 1576e15 commit a65d52d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ public void initialize(ApplicationInfo appInfo, Collection<? extends Sniffer> sn
currentDeploymentContext.get().pop();
}
}

@Override
public ApplicationInfo deploy(final ExtendedDeploymentContext context) {
return deploy(null, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.sun.enterprise.util.io.FileUtils;
import com.sun.enterprise.admin.report.HTMLActionReporter;
import com.sun.enterprise.v3.bootstrap.BootCommandService;
import fish.payara.enterprise.config.serverbeans.DeploymentGroup;
import java.io.File;
import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -408,7 +409,7 @@ public List<Deployment.ApplicationDeployment> processApplication(Application app

DeployCommandParameters deploymentParams =
app.getDeployParameters(appRef);
deploymentParams.target = server.getName();
deploymentParams.target = validateAndGetTargetName(appName, server.getName());
deploymentParams.origin = DeployCommandParameters.Origin.load;
deploymentParams.command = DeployCommandParameters.Command.startup_server;
if (domain.isAppReferencedByPaaSTarget(appName)) {
Expand Down Expand Up @@ -462,6 +463,29 @@ public List<Deployment.ApplicationDeployment> processApplication(Application app
return appDeployments;
}

/**
* Evaluate Target name against Deployment groups and returns correct name for deployment process
* @param appName application name
* @param serverName specified server name to evaluate
* @return String that represents target name
*/
public String validateAndGetTargetName(String appName, String serverName) {
List<String> targets = domain.getAllReferencedTargetsForApplication(appName);
if (targets.isEmpty()) {
return serverName;
}

String targetName = targets.get(0);
java.util.Optional<DeploymentGroup> optDG = domain.getDeploymentGroups().getDeploymentGroup().
stream().filter(d -> d.getName().equals(targetName)).findAny();

if (optDG.isPresent()) {
return optDG.get().getName();
}

return targetName;
}


public String toString() {
return "Application Loader";
Expand Down Expand Up @@ -636,4 +660,4 @@ private boolean loadAppOnDAS(String appName) {
}
return false;
}
}
}

0 comments on commit a65d52d

Please sign in to comment.