private RollingUpdateOp rollingUpdateAwaitUndeployed(final ZooKeeperClient client, final RollingUpdateOpFactory opFactory, final DeploymentGroup deploymentGroup, final String host) { final TaskStatus taskStatus = getTaskStatus(client, host, deploymentGroup.getJobId()); if (taskStatus == null) { // The task status (i.e. /status/hosts/<host>/job/<job-id>) has been removed, indicating the // job has been undeployed. return opFactory.nextTask(); } if (isRolloutTimedOut(client, deploymentGroup)) { return opFactory.error("timed out while waiting for job undeployment", host, RollingUpdateError.TIMED_OUT_WAITING_FOR_JOB_TO_UNDEPLOY); } return opFactory.yield(); }
private RollingUpdateOp rollingUpdateDeploy(final ZooKeeperClient client, final RollingUpdateOpFactory opFactory, final DeploymentGroup deploymentGroup, final String host) { final Deployment deployment = Deployment.of(deploymentGroup.getJobId(), Goal.START, Deployment.EMTPY_DEPLOYER_USER, this.name, deploymentGroup.getName()); try { final String token = MoreObjects.firstNonNull( deploymentGroup.getRolloutOptions().getToken(), Job.EMPTY_TOKEN); return opFactory.nextTask(getDeployOperations(client, host, deployment, token)); } catch (JobDoesNotExistException e) { return opFactory.error(e, host, RollingUpdateError.JOB_NOT_FOUND); } catch (TokenVerificationException e) { return opFactory.error(e, host, RollingUpdateError.TOKEN_VERIFICATION_ERROR); } catch (HostNotFoundException e) { return opFactory.error(e, host, RollingUpdateError.HOST_NOT_FOUND); } catch (JobPortAllocationConflictException e) { return opFactory.error(e, host, RollingUpdateError.PORT_CONFLICT); } catch (JobAlreadyDeployedException e) { // Nothing to do return opFactory.nextTask(); } }
.build(); return new RollingUpdateOpFactory(tasks, DEPLOYMENT_GROUP_EVENT_FACTORY) .start(deploymentGroup, zooKeeperClient);
final String errMsg = isNullOrEmpty(host) ? msg : host + ": " + msg; if (isIgnoreFailures()) { log.info( "would have set state=FAILED for deploymentGroup={} but ignoreFailures is set to true " deploymentGroup.getName(), errorCode, errMsg); return nextTask(operations);
public RollingUpdateOp error(final String msg, final String host, final RollingUpdateError errorCode) { return error(msg, host, errorCode, Collections.<String, Object>emptyMap()); }
public RollingUpdateOp nextTask() { return nextTask(Collections.<ZooKeeperOperation>emptyList()); }
final RollingUpdateOpFactory opFactory = new RollingUpdateOpFactory( tasks, DEPLOYMENT_GROUP_EVENT_FACTORY); final RolloutTask task = tasks.getRolloutTasks().get(taskIndex);
private RollingUpdateOp rollingUpdateUndeploy(final ZooKeeperClient client, final RollingUpdateOpFactory opFactory, final DeploymentGroup deploymentGroup, final String host, final boolean skipRedundantUndeploys) { final List<ZooKeeperOperation> operations = Lists.newArrayList(); for (final Deployment deployment : getTasks(client, host).values()) { if (!ownedByDeploymentGroup(deployment, deploymentGroup) && !isMigration(deployment, deploymentGroup)) { continue; } if (skipRedundantUndeploys && redundantUndeployment(deployment, deploymentGroup)) { continue; } try { final String token = MoreObjects.firstNonNull( deploymentGroup.getRolloutOptions().getToken(), Job.EMPTY_TOKEN); operations.addAll(getUndeployOperations(client, host, deployment.getJobId(), token)); log.debug("planned undeploy operations for job={}", deployment.getJobId()); } catch (TokenVerificationException e) { return opFactory.error(e, host, RollingUpdateError.TOKEN_VERIFICATION_ERROR); } catch (HostNotFoundException e) { return opFactory.error(e, host, RollingUpdateError.HOST_NOT_FOUND); } catch (JobNotDeployedException e) { // probably somebody beat us to the punch of undeploying. that's fine. } } return opFactory.nextTask(operations); }
public RollingUpdateOp error(final Exception ex, final String host, final RollingUpdateError errorCode) { final String message; if (errorCode == RollingUpdateError.PORT_CONFLICT) { message = ex.getMessage() + " (the conflicting job was deployed manually or by a different deployment group)"; } else { message = ex.getMessage(); } return error(message, host, errorCode); } }
return opFactory.error( "Job unexpectedly undeployed. Perhaps it was manually undeployed?", host, RollingUpdateError.JOB_UNEXPECTEDLY_UNDEPLOYED); return opFactory.error("timed out while retrieving job status", host, RollingUpdateError.TIMED_OUT_RETRIEVING_JOB_STATUS); return opFactory.yield(); } else if (!taskStatus.getState().equals(TaskStatus.State.RUNNING)) { return opFactory.yield(); } else { return opFactory.error( "deployment for this job not found in zookeeper. " + "Perhaps it was manually undeployed?", host, RollingUpdateError.JOB_UNEXPECTEDLY_UNDEPLOYED); } else if (!Objects.equals(deployment.getDeploymentGroupName(), deploymentGroup.getName())) { return opFactory.error( "job was already deployed, either manually or by a different deployment group", host, RollingUpdateError.JOB_ALREADY_DEPLOYED); return opFactory.nextTask();
return opFactory.nextTask(); return opFactory.nextTask(ImmutableList.of( check(Paths.statusDeploymentGroupRemovedHosts(deploymentGroup.getName()), version), set(Paths.statusDeploymentGroupRemovedHosts(deploymentGroup.getName()), Json.asBytes(hostsToUndeploy)))); } catch (KeeperException | IOException e) { return opFactory.error("unable to mark host undeployed after removal from deployment group", host, RollingUpdateError.UNABLE_TO_MARK_HOST_UNDEPLOYED);
return opFactory.error( baseError + "due to missing Docker image " + stateInfo, host, return opFactory.error( baseError + "due to failure pulling Docker image " + stateInfo, host, return opFactory.error( baseError + stateInfo + " container error: " + taskStatus.getContainerError(), host, metadata); return opFactory.error( baseError + stateInfo, host,