Skip to content

Commit

Permalink
fix: bootstrap on rollback when component breaks (#1555)
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-mage authored Oct 31, 2023
1 parent cf9871d commit 8077a67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.aws.greengrass.deployment;

import com.aws.greengrass.componentmanager.ComponentManager;
import com.aws.greengrass.deployment.bootstrap.BootstrapManager;
import com.aws.greengrass.deployment.errorcode.DeploymentErrorCode;
import com.aws.greengrass.deployment.errorcode.DeploymentErrorCodeUtils;
import com.aws.greengrass.deployment.errorcode.DeploymentErrorType;
Expand Down Expand Up @@ -94,10 +95,14 @@ public DeploymentResult call() {
logger.atError("deployment-errored", e).log();
if (KERNEL_ACTIVATION.equals(stage)) {
try {
deployment.setDeploymentStage(KERNEL_ROLLBACK);
KernelAlternatives kernelAlternatives = kernel.getContext().get(KernelAlternatives.class);
final boolean bootstrapOnRollbackRequired = kernelAlternatives.prepareBootstrapOnRollbackIfNeeded(
kernel.getContext(), kernel.getContext().get(DeploymentDirectoryManager.class),
kernel.getContext().get(BootstrapManager.class));
deployment.setDeploymentStage(bootstrapOnRollbackRequired ? ROLLBACK_BOOTSTRAP : KERNEL_ROLLBACK);
saveDeploymentStatusDetails(e);
// Rollback workflow. Flip symlinks and restart kernel
kernel.getContext().get(KernelAlternatives.class).prepareRollback();
kernelAlternatives.prepareRollback();
kernel.shutdown(30, REQUEST_RESTART);
} catch (IOException ioException) {
logger.atError().log("Failed to set up Nucleus rollback directory", ioException);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public boolean prepareBootstrapOnRollbackIfNeeded(Context context,
logger.atError().log("Failed to read rollback snapshot config", exc);
return false;
}
boolean bootstrapOnRollbackRequired = false;
boolean bootstrapOnRollbackRequired;
try {
// Check if we need to execute component bootstrap steps during the rollback deployment.
final Set<String> componentsToExclude =
Expand Down

0 comments on commit 8077a67

Please sign in to comment.