-
Notifications
You must be signed in to change notification settings - Fork 42
Bg stop reorder #1761
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
base: master
Are you sure you want to change the base?
Bg stop reorder #1761
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -195,6 +195,8 @@ public class Messages { | |
| public static final String ERROR_WHILE_DETERMINING_SERVICE_KEYS_TO_RECREATE = "Error while determining service keys to recreate"; | ||
| public static final String ERROR_WHILE_UPDATING_SERVICE_KEYS_METADATA = "Error while updating service keys metadata"; | ||
| public static final String ERROR_WHILE_POLLING_SERVICE_KEY_OPERATION_0 = "Error while polling service key operation \"{0}\""; | ||
| public static final String ERROR_WHILE_STOPPING_DEPENDENT_MODULES = "Failed to stop dependent module with name \"{0}\""; | ||
| public static final String ERROR_WHEN_CONFIGURING_STOPPING_OF_DEPENDENT_MODULES = "Failed when configuring the stopping of dependent modules \"{0}\""; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All other error messages are combination of ERROR + WHILE, only this is with WHEN, do you think that it can be renamed for consistency? |
||
|
|
||
| public static final String ERROR_WHILE_BACKUP_APPLICATION = "Error while backup applcation \"{0}\""; | ||
| public static final String ERROR_DURING_PREPARATION_BACKUP_MTA = "Error during preparation backup mta for rollback deployment"; | ||
|
|
@@ -271,6 +273,8 @@ public class Messages { | |
| public static final String SERVICE_INSTANCE_0_PARAMETERS_UPDATE_FAILED_IGNORING_FAILURE = "Service instance: \"{0}\" parameters update failed, ignoring failure..."; | ||
| public static final String SERVICE_INSTANCE_0_TAGS_UPDATE_FAILED_IGNORING_FAILURE = "Service instance: \"{0}\" tags update failed, ignoring failure..."; | ||
| public static final String ONLY_FIRST_SERVICE_WILL_BE_CREATED = "Only the first service will be created because the provided 'service-name' fields are duplicated! All other services with the same 'service-name' will be ignored! Duplicated names: {0}"; | ||
| public static final String SKIPPING_DEPENDENCY_ORDER_STOP = "Skipping stopping modules in dependency-aware order. This feature is reserved only for blue green deployment strategy."; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it is used for blue-green deployment you may add it to the constant name, you may also consider "available for" instead of "reserved only". |
||
| public static final String UNSUPPORTED_DEPLOYED_AFTER_SCHEMA_VERSION_WARNING = "Skipping module \"{0}\": major schema version \"{1}\" does not support 'deployed-after' (minimum supported version is \"{2}\")."; | ||
|
|
||
| // INFO log messages | ||
| public static final String ACQUIRING_LOCK = "Process \"{0}\" attempting to acquire lock for operation on MTA \"{1}\""; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package org.cloudfoundry.multiapps.controller.process.steps; | ||
|
|
||
| import java.text.MessageFormat; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| import jakarta.inject.Inject; | ||
| import jakarta.inject.Named; | ||
| import org.cloudfoundry.multiapps.controller.client.facade.domain.CloudRoute; | ||
| import org.cloudfoundry.multiapps.controller.client.lib.domain.CloudApplicationExtended; | ||
| import org.cloudfoundry.multiapps.controller.client.lib.domain.ImmutableCloudApplicationExtended; | ||
| import org.cloudfoundry.multiapps.controller.core.cf.v2.ApplicationCloudModelBuilder; | ||
| import org.cloudfoundry.multiapps.controller.core.helpers.ModuleToDeployHelper; | ||
| import org.cloudfoundry.multiapps.controller.process.Messages; | ||
| import org.cloudfoundry.multiapps.controller.process.util.ApplicationEnvironmentCalculator; | ||
| import org.cloudfoundry.multiapps.controller.process.variables.Variables; | ||
| import org.cloudfoundry.multiapps.mta.handlers.HandlerFactory; | ||
| import org.cloudfoundry.multiapps.mta.model.DeploymentDescriptor; | ||
| import org.cloudfoundry.multiapps.mta.model.Module; | ||
| import org.springframework.beans.factory.config.BeanDefinition; | ||
| import org.springframework.context.annotation.Scope; | ||
|
|
||
| @Named("prepareToStopDependentModuleStep") | ||
| @Scope(BeanDefinition.SCOPE_PROTOTYPE) | ||
| public class PrepareToStopDependentModuleStep extends SyncFlowableStep { | ||
|
|
||
| private ModuleToDeployHelper moduleToDeployHelper; | ||
|
|
||
| private ApplicationEnvironmentCalculator applicationEnvironmentCalculator; | ||
|
|
||
| @Inject | ||
| public PrepareToStopDependentModuleStep(ModuleToDeployHelper moduleToDeployHelper, | ||
| ApplicationEnvironmentCalculator applicationEnvironmentCalculator) { | ||
| this.moduleToDeployHelper = moduleToDeployHelper; | ||
| this.applicationEnvironmentCalculator = applicationEnvironmentCalculator; | ||
| } | ||
|
|
||
| @Override | ||
| protected StepPhase executeStep(ProcessContext context) { | ||
| Module applicationModule = findModuleInDeploymentDescriptor(context, getCurrentModuleToStop(context).getName()); | ||
| context.setVariable(Variables.MODULE_TO_DEPLOY, applicationModule); | ||
| CloudApplicationExtended modifiedApp = getApplicationCloudModelBuilder(context).build(applicationModule, moduleToDeployHelper); | ||
| Map<String, String> calculatedAppEnv = applicationEnvironmentCalculator.calculateNewApplicationEnv(context, modifiedApp); | ||
| modifiedApp = getCloudApplicationExtended(context, modifiedApp, calculatedAppEnv); | ||
| context.setVariable(Variables.APP_TO_PROCESS, modifiedApp); | ||
| return StepPhase.DONE; | ||
| } | ||
|
|
||
| private CloudApplicationExtended getCloudApplicationExtended(ProcessContext context, CloudApplicationExtended modifiedApp, | ||
| Map<String, String> calculatedAppEnv) { | ||
| return ImmutableCloudApplicationExtended.builder() | ||
| .from(modifiedApp) | ||
| .staging(modifiedApp.getStaging()) | ||
| .routes(getApplicationRoutes(context, modifiedApp)) | ||
| .env(calculatedAppEnv) | ||
| .build(); | ||
| } | ||
|
|
||
| protected ApplicationCloudModelBuilder getApplicationCloudModelBuilder(ProcessContext context) { | ||
| return StepsUtil.getApplicationCloudModelBuilder(context); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getStepErrorMessage(ProcessContext context) { | ||
| return MessageFormat.format(Messages.ERROR_WHILE_STOPPING_DEPENDENT_MODULES, context.getVariable(Variables.APP_TO_PROCESS) | ||
| .getName()); | ||
| } | ||
|
|
||
| private Module getCurrentModuleToStop(ProcessContext context) { | ||
| List<Module> modules = context.getVariable(Variables.DEPENDENT_MODULES_TO_STOP); | ||
| int index = context.getVariable(Variables.APPS_TO_STOP_INDEX); | ||
| return modules.get(index); | ||
| } | ||
|
|
||
| private Module findModuleInDeploymentDescriptor(ProcessContext context, String module) { | ||
| HandlerFactory handlerFactory = StepsUtil.getHandlerFactory(context.getExecution()); | ||
| DeploymentDescriptor deploymentDescriptor = context.getVariable(Variables.COMPLETE_DEPLOYMENT_DESCRIPTOR); | ||
| return handlerFactory.getDescriptorHandler() | ||
| .findModule(deploymentDescriptor, module); | ||
| } | ||
|
|
||
| private Set<CloudRoute> getApplicationRoutes(ProcessContext context, CloudApplicationExtended modifiedApp) { | ||
| if (Boolean.TRUE.equals(context.getVariable(Variables.USE_IDLE_URIS))) { | ||
| return modifiedApp.getIdleRoutes(); | ||
| } | ||
| return modifiedApp.getRoutes(); | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant name is plural, but the text is not, do you think that it should be aligned?
_DEPENDENT_MODULES -> _DEPENDENT_MODULE?