use of com.aws.greengrass.deployment.bootstrap.BootstrapSuccessCode.REQUEST_RESTART in project aws-greengrass-nucleus by aws-greengrass.
the class KernelUpdateDeploymentTask method call.
@SuppressWarnings({ "PMD.AvoidDuplicateLiterals" })
@Override
public DeploymentResult call() {
Deployment.DeploymentStage stage = deployment.getDeploymentStage();
try {
List<GreengrassService> servicesToTrack = kernel.orderedDependencies().stream().filter(GreengrassService::shouldAutoStart).filter(o -> !kernel.getMain().equals(o)).collect(Collectors.toList());
long mergeTimestamp = kernel.getConfig().lookup("system", "rootpath").getModtime();
logger.atDebug().kv("serviceToTrack", servicesToTrack).kv("mergeTime", mergeTimestamp).log("Nucleus update workflow waiting for services to complete update");
DeploymentConfigMerger.waitForServicesToStart(servicesToTrack, mergeTimestamp);
DeploymentResult result = null;
if (KERNEL_ACTIVATION.equals(stage)) {
result = new DeploymentResult(DeploymentResult.DeploymentStatus.SUCCESSFUL, null);
} else if (KERNEL_ROLLBACK.equals(stage)) {
result = new DeploymentResult(DeploymentResult.DeploymentStatus.FAILED_ROLLBACK_COMPLETE, getDeploymentStatusDetails());
}
componentManager.cleanupStaleVersions();
return result;
} catch (InterruptedException e) {
logger.atError("deployment-interrupted", e).log();
try {
saveDeploymentStatusDetails(e.getMessage());
} catch (IOException ioException) {
logger.atError().log("Failed to persist deployment error information", ioException);
}
// Interrupted workflow. Shutdown kernel and retry this stage.
kernel.shutdown(30, REQUEST_RESTART);
return null;
} catch (ServiceUpdateException e) {
logger.atError("deployment-errored", e).log();
if (KERNEL_ACTIVATION.equals(stage)) {
try {
deployment.setDeploymentStage(KERNEL_ROLLBACK);
saveDeploymentStatusDetails(e.getMessage());
// Rollback workflow. Flip symlinks and restart kernel
kernel.getContext().get(KernelAlternatives.class).prepareRollback();
kernel.shutdown(30, REQUEST_RESTART);
} catch (IOException ioException) {
logger.atError().log("Failed to set up Nucleus rollback directory", ioException);
return new DeploymentResult(DeploymentResult.DeploymentStatus.FAILED_UNABLE_TO_ROLLBACK, e);
}
return null;
} else if (KERNEL_ROLLBACK.equals(stage)) {
logger.atError().log("Nucleus update workflow failed on rollback", e);
return new DeploymentResult(DeploymentResult.DeploymentStatus.FAILED_UNABLE_TO_ROLLBACK, getDeploymentStatusDetails());
}
return null;
}
}
Aggregations