Add phase-configs support to Hook model for target-app resolution#1812
Merged
IvanBorislavovDimitrov merged 13 commits intoMay 13, 2026
Merged
Conversation
20deee7 to
0827e89
Compare
…reen deployments Route hook task execution to idle or live app based on phase-configs in the hook descriptor. Pass idleMtaColor, liveMtaColor, subprocessPhase and phase variables to all hook call activities in BPMN processes. Add determineDeploymentTypeSafely to avoid SERVICE_ID lookup failures in hook subprocesses. # Conflicts: # pom.xml
buildCurrentPhaseString was always picking the first phase from hook.getPhases(), causing wrong target-app resolution when a hook registered for multiple phases fired during a later phase. Also fixed getDeploymentTypeString returning "deploy" instead of "blue-green" inside hook subprocesses where SERVICE_ID is absent. Introduced HOOK_EXECUTION_PHASE variable set by HooksExecutor to record which phase triggered the current hook execution. ExecuteTaskStep now matches against this value to find the correct phase-config entry. Variable is passed to all hook call activities in deploy-app, undeploy-app, backup-existing-app and stop-dependent-modules BPMNs.
0827e89 to
c5bab3b
Compare
c5bab3b to
9165d29
Compare
13a5600 to
7deb07c
Compare
vkalapov
requested changes
May 12, 2026
Comment on lines
+43
to
+66
| private String resolveTargetAppName(ProcessContext context, CloudApplicationExtended app) { | ||
| Hook hook = context.getVariable(Variables.HOOK_FOR_EXECUTION); | ||
| if (hook == null) { | ||
| return app.getName(); | ||
| } | ||
|
|
||
| List<Map<String, String>> phasesConfig = getPhasesConfig(hook); | ||
| if (phasesConfig.isEmpty()) { | ||
| return app.getName(); | ||
| } | ||
|
|
||
| String currentPhase = buildCurrentPhaseString(context, hook); | ||
| String targetApp = phasesConfig.stream() | ||
| .filter(config -> currentPhase.equals(config.get(PHASE_KEY))) | ||
| .map(config -> config.get(TARGET_APP_KEY)) | ||
| .findFirst() | ||
| .orElse(null); | ||
|
|
||
| if (targetApp == null) { | ||
| return app.getName(); | ||
| } | ||
|
|
||
| return resolveAppNameForTarget(context, app, targetApp); | ||
| } |
Contributor
There was a problem hiding this comment.
Small refactoring suggestion: app.getName() is returned in multiple branches here. Consider assigning it as the default result and only changing it when a target app is found, to reduce repetition.
Contributor
Author
There was a problem hiding this comment.
The suggested refactoring would work if resolveAppNameForTarget always returns a non-null value, but resolveLiveAppName returns null as a sentinel to signal that the hook execution should be skipped (initial deploy, no live app exists). Using Optional.map() with a lambda that can return null throws a NPE.
IvanBorislavovDimitrov
previously approved these changes
May 12, 2026
vkalapov
approved these changes
May 13, 2026
IvanBorislavovDimitrov
approved these changes
May 13, 2026
53e6e56
into
cloudfoundry:master
4 of 6 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LMCROSSITXSADEPLOY-3038