-
Notifications
You must be signed in to change notification settings - Fork 44
remove idle suffix from bg deploy #1697
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?
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 |
|---|---|---|
|
|
@@ -37,127 +37,6 @@ paths: | |
| $ref: "#/definitions/Info" | ||
| security: | ||
| - oauth2: [] | ||
| /api/v1/spaces/{spaceGuid}/files: | ||
| get: | ||
| summary: "" | ||
| description: "Retrieves all Multi-Target Application files " | ||
| operationId: "getMtaFiles" | ||
| produces: | ||
| - "application/json" | ||
| parameters: | ||
| - name: "spaceGuid" | ||
| in: "path" | ||
| description: "GUID of space with mtas" | ||
| required: true | ||
| type: "string" | ||
| - name: "namespace" | ||
| in: "query" | ||
| description: "Filter mtas by namespace" | ||
| required: false | ||
| type: "string" | ||
| responses: | ||
| 200: | ||
| description: "OK" | ||
| schema: | ||
| type: "array" | ||
| items: | ||
| $ref: "#/definitions/FileMetadata" | ||
| security: | ||
| - oauth2: [] | ||
| post: | ||
| summary: "" | ||
| description: "Uploads a Multi Target Application archive or an Extension Descriptor " | ||
| operationId: "uploadMtaFile" | ||
| consumes: | ||
| - "multipart/form-data" | ||
| produces: | ||
| - "application/json" | ||
| parameters: | ||
| - name: "spaceGuid" | ||
| in: "path" | ||
| description: "GUID of space you wish to deploy in" | ||
| required: true | ||
| type: "string" | ||
| - name: "namespace" | ||
| in: "query" | ||
| description: "file namespace" | ||
| required: false | ||
| type: "string" | ||
| responses: | ||
| 200: | ||
| description: "successful operation" | ||
| schema: | ||
| $ref: "#/definitions/FileMetadata" | ||
| 201: | ||
| description: "Created" | ||
| schema: | ||
| $ref: "#/definitions/FileMetadata" | ||
| security: | ||
| - oauth2: [] | ||
| /api/v1/spaces/{spaceGuid}/files/async: | ||
| post: | ||
| summary: "" | ||
| description: "Uploads a Multi Target Application archive or an Extension Descriptor\ | ||
| \ from a remote endpoint" | ||
| operationId: "startUploadFromUrl" | ||
| consumes: | ||
| - "application/json" | ||
| parameters: | ||
| - name: "spaceGuid" | ||
| in: "path" | ||
| description: "GUID of space you wish to deploy in" | ||
| required: true | ||
| type: "string" | ||
| - name: "namespace" | ||
| in: "query" | ||
| description: "file namespace" | ||
| required: false | ||
| type: "string" | ||
| - in: "body" | ||
| name: "body" | ||
| description: "URL reference to a remote file" | ||
| required: false | ||
| schema: | ||
| $ref: "#/definitions/FileUrl" | ||
| responses: | ||
| 202: | ||
| description: "Accepted" | ||
| security: | ||
| - oauth2: [] | ||
| /api/v1/spaces/{spaceGuid}/files/jobs/{jobId}: | ||
| get: | ||
| summary: "" | ||
| description: "Gets the status of an async upload job" | ||
| operationId: "getAsyncUploadJob" | ||
| produces: | ||
| - "application/json" | ||
| parameters: | ||
| - name: "spaceGuid" | ||
| in: "path" | ||
| description: "GUID of space you wish to deploy in" | ||
| required: true | ||
| type: "string" | ||
| - name: "namespace" | ||
| in: "query" | ||
| description: "file namespace" | ||
| required: false | ||
| type: "string" | ||
| - name: "jobId" | ||
| in: "path" | ||
| description: "ID of the upload job" | ||
| required: true | ||
| type: "string" | ||
| responses: | ||
| 200: | ||
| description: "OK" | ||
| schema: | ||
| $ref: "#/definitions/AsyncUploadResult" | ||
| 201: | ||
| description: "Created" | ||
| schema: | ||
| $ref: "#/definitions/AsyncUploadResult" | ||
| security: | ||
| - oauth2: [] | ||
| /api/v1/spaces/{spaceGuid}/mtas: | ||
| get: | ||
| summary: "" | ||
|
|
@@ -403,66 +282,6 @@ securityDefinitions: | |
| flow: "password" | ||
| scopes: {} | ||
| definitions: | ||
| AsyncUploadResult: | ||
|
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. same |
||
| type: "object" | ||
| properties: | ||
| status: | ||
| type: "string" | ||
| readOnly: true | ||
| enum: | ||
| - "RUNNING" | ||
| - "FINISHED" | ||
| - "ERROR" | ||
| bytes_processed: | ||
| type: "integer" | ||
| format: "int64" | ||
| readOnly: true | ||
| error: | ||
| type: "string" | ||
| readOnly: true | ||
| file: | ||
| readOnly: true | ||
| $ref: "#/definitions/FileMetadata" | ||
| mta_id: | ||
| type: "string" | ||
| readOnly: true | ||
| client_actions: | ||
| type: "array" | ||
| readOnly: true | ||
| items: | ||
| type: "string" | ||
| enum: | ||
| - "RETRY_UPLOAD" | ||
| FileMetadata: | ||
| type: "object" | ||
| properties: | ||
| id: | ||
| type: "string" | ||
| readOnly: true | ||
| name: | ||
| type: "string" | ||
| readOnly: true | ||
| size: | ||
| type: "integer" | ||
| readOnly: true | ||
| digest: | ||
| type: "string" | ||
| readOnly: true | ||
| digestAlgorithm: | ||
| type: "string" | ||
| readOnly: true | ||
| space: | ||
| type: "string" | ||
| readOnly: true | ||
| namespace: | ||
| type: "string" | ||
| readOnly: true | ||
| FileUrl: | ||
| type: "object" | ||
| properties: | ||
| file_url: | ||
| type: "string" | ||
| readOnly: true | ||
| Info: | ||
| type: "object" | ||
| properties: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| import org.cloudfoundry.multiapps.controller.client.facade.CloudControllerClient; | ||
| import org.cloudfoundry.multiapps.controller.client.facade.CloudCredentials; | ||
| import org.cloudfoundry.multiapps.controller.client.facade.domain.CloudApplication; | ||
| import org.cloudfoundry.multiapps.controller.client.facade.domain.ImmutableCloudApplication; | ||
| import org.cloudfoundry.multiapps.controller.client.facade.domain.ImmutableStaging; | ||
| import org.cloudfoundry.multiapps.controller.client.facade.domain.Staging; | ||
| import org.cloudfoundry.multiapps.controller.client.facade.dto.ApplicationToCreateDto; | ||
|
|
@@ -28,8 +29,11 @@ | |
| import org.cloudfoundry.multiapps.controller.core.cf.clients.AppBoundServiceInstanceNamesGetter; | ||
| import org.cloudfoundry.multiapps.controller.core.cf.clients.WebClientFactory; | ||
| import org.cloudfoundry.multiapps.controller.core.helpers.ApplicationFileDigestDetector; | ||
| import org.cloudfoundry.multiapps.controller.core.model.BlueGreenApplicationNameSuffix; | ||
| import org.cloudfoundry.multiapps.controller.core.security.token.TokenService; | ||
| import org.cloudfoundry.multiapps.controller.core.util.ApplicationConfiguration; | ||
| import org.cloudfoundry.multiapps.controller.persistence.model.ConfigurationSubscription; | ||
| import org.cloudfoundry.multiapps.controller.persistence.services.ConfigurationSubscriptionService; | ||
| import org.cloudfoundry.multiapps.controller.persistence.services.FileStorageException; | ||
| import org.cloudfoundry.multiapps.controller.process.Messages; | ||
| import org.cloudfoundry.multiapps.controller.process.util.ApplicationAttributeUpdater; | ||
|
|
@@ -59,6 +63,8 @@ public class CreateOrUpdateAppStep extends SyncFlowableStep { | |
| private WebClientFactory webClientFactory; | ||
| @Inject | ||
| private ApplicationConfiguration configuration; | ||
| @Inject | ||
| private ConfigurationSubscriptionService subscriptionService; | ||
|
|
||
| @Override | ||
| protected StepPhase executeStep(ProcessContext context) throws FileStorageException { | ||
|
|
@@ -95,7 +101,9 @@ protected AppBoundServiceInstanceNamesGetter getAppBoundServiceInstanceNamesGett | |
| return new AppBoundServiceInstanceNamesGetter(configuration, webClientFactory, credentials, correlationId); | ||
| } | ||
|
|
||
| private StepFlowHandler createStepFlowHandler(ProcessContext context, CloudControllerClient client, CloudApplicationExtended app, | ||
| private StepFlowHandler createStepFlowHandler(ProcessContext context, | ||
| CloudControllerClient client, | ||
| CloudApplicationExtended app, | ||
| CloudApplication existingApp) { | ||
| if (existingApp == null) { | ||
| return new CreateAppFlowHandler(context, client, app); | ||
|
|
@@ -213,7 +221,9 @@ private class UpdateAppFlowHandler extends StepFlowHandler { | |
|
|
||
| final CloudApplication existingApp; | ||
|
|
||
| public UpdateAppFlowHandler(ProcessContext context, CloudControllerClient client, CloudApplicationExtended app, | ||
| public UpdateAppFlowHandler(ProcessContext context, | ||
| CloudControllerClient client, | ||
| CloudApplicationExtended app, | ||
| CloudApplication existingApp) { | ||
| super(context, client, app); | ||
| this.existingApp = existingApp; | ||
|
|
@@ -231,7 +241,9 @@ public void handleApplicationAttributes() { | |
|
|
||
| reportApplicationUpdateStatus(app, arePropertiesChanged); | ||
| context.setVariable(Variables.VCAP_APP_PROPERTIES_CHANGED, arePropertiesChanged); | ||
|
|
||
| updateApplicationEnvironment(); | ||
| updateApplicationName(); | ||
| } | ||
|
|
||
| private void updateApplicationEnvironment() { | ||
|
|
@@ -279,6 +291,31 @@ private UpdateStrategy getEnvUpdateStrategy() { | |
| .shouldKeepExistingEnv() ? UpdateStrategy.MERGE : UpdateStrategy.REPLACE; | ||
| } | ||
|
|
||
| public void updateApplicationName() { | ||
| boolean processIsBlueGreenWithIdleSuffix = StepsUtil.getAppSuffixDeterminer(context) | ||
|
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. maybe rename to isBlueGreenProcessAfterResumePhase or something?
Contributor
Author
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. the current name seems more clear since this is only for blueGreen with idle, not with colours |
||
| .shouldAppendIdleSuffix(); | ||
| if (!processIsBlueGreenWithIdleSuffix) { | ||
| return; | ||
| } | ||
|
|
||
| String oldName = existingApp.getName(); | ||
| String newName = BlueGreenApplicationNameSuffix.removeSuffix(oldName); | ||
| if (oldName.equals(newName)) { | ||
|
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. when this check will return true?
Contributor
Author
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. will double-check - in general if the new app happens to have the same name (not blue-green deploy?)
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. if it is not the not blue green, will it even reach this condition? Maybe during retry? |
||
| getStepLogger().info(Messages.THE_DETECTED_APPLICATION_HAS_THE_SAME_NAME_AS_THE_NEW_ONE); | ||
| return; | ||
|
Comment on lines
+304
to
+305
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. Can a rename here make this step non-idempotent? What will happen if the step fails during the update of the configuration entries? Or for example instance get shutdown and it gets re-executed by flowable? |
||
| } | ||
|
|
||
| getStepLogger().info(Messages.RENAMING_APPLICATION_0_TO_1, oldName, newName); | ||
| client.rename(oldName, newName); | ||
|
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. What will happen if the MTA operation fail in the resume phase? I mean if the restart of the rename application (now without suffix fails) and the customer executes a new deployment, will the new process detect the "-live" applications as actually live? Is it possible for the new operation to detect the wrong application as live?
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. I'm writing this comment because now the renaming is before the restart/restage, which is a potential point of failure. |
||
|
|
||
| context.setVariable(Variables.EXISTING_APP, ImmutableCloudApplication.copyOf(existingApp) | ||
| .withName(newName)); | ||
| context.setVariable(Variables.APP_TO_PROCESS, ImmutableCloudApplicationExtended.copyOf(app) | ||
| .withName(newName)); | ||
|
|
||
| updateConfigurationSubscribers(oldName, newName); | ||
| } | ||
|
|
||
| @Override | ||
| public void handleApplicationServices() { | ||
| if (context.getVariable(Variables.SHOULD_SKIP_SERVICE_REBINDING)) { | ||
|
|
@@ -298,6 +335,40 @@ public void printStepEndMessage() { | |
| getStepLogger().debug(Messages.APP_UPDATED, app.getName()); | ||
| } | ||
|
|
||
| private void updateConfigurationSubscribers(String oldAppName, String newAppName) { | ||
| String mtaId = context.getVariable(Variables.MTA_ID); | ||
| String spaceGuid = context.getVariable(Variables.SPACE_GUID); | ||
|
|
||
| List<ConfigurationSubscription> subscriptions = subscriptionService.createQuery() | ||
| .mtaId(mtaId) | ||
| .spaceId(spaceGuid) | ||
| .list(); | ||
| for (ConfigurationSubscription subscription : subscriptions) { | ||
| if (oldAppName.equals(subscription.getAppName())) { | ||
| getStepLogger().debug(Messages.UPDATING_CONFIGURATION_SUBSCRIPTION_0_WITH_NAME_1, subscription.getAppName(), | ||
| newAppName); | ||
| updateConfigurationSubscription(subscription, newAppName); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private void updateConfigurationSubscription(ConfigurationSubscription subscription, String newAppName) { | ||
| ConfigurationSubscription newSubscription = createNewSubscription(subscription, newAppName); | ||
| subscriptionService.update(subscription, newSubscription); | ||
| } | ||
|
|
||
| private ConfigurationSubscription createNewSubscription(ConfigurationSubscription subscription, String newAppName) { | ||
| return new ConfigurationSubscription(subscription.getId(), | ||
| subscription.getMtaId(), | ||
| subscription.getSpaceId(), | ||
| newAppName, | ||
| subscription.getFilter(), | ||
| subscription.getModuleDto(), | ||
| subscription.getResourceDto(), | ||
| subscription.getModuleId(), | ||
| subscription.getResourceId()); | ||
| } | ||
|
|
||
| private List<String> getMtaAndExistingServices() { | ||
| var serviceNamesGetter = getAppBoundServiceInstanceNamesGetter(context); | ||
| return Stream.of(app.getServices(), serviceNamesGetter.getServiceInstanceNamesBoundToApp(existingApp.getGuid())) | ||
|
|
||
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.
Do not delete this. Must be checked why always deleted after build