use of com.epam.pipeline.controller.vo.PipelineRunServiceUrlVO in project cloud-pipeline by epam.
the class DockerContainerOperationManager method pauseRun.
@Async("pauseRunExecutor")
public void pauseRun(PipelineRun run) {
try {
final String containerId = kubernetesManager.getContainerIdFromKubernetesPod(run.getPodId(), run.getDockerImage());
final String apiToken = authManager.issueTokenForCurrentUser().getToken();
Assert.notNull(containerId, messageHelper.getMessage(MessageConstants.ERROR_CONTAINER_ID_FOR_RUN_NOT_FOUND, run.getId()));
String pauseRunCommand = String.format(PAUSE_COMMAND_TEMPLATE, pauseRunScriptUrl, preferenceManager.getPreference(SystemPreferences.BASE_API_HOST), apiToken, commitScriptsDistributionsUrl, preferenceManager.getPreference(SystemPreferences.BASE_PIPE_DISTR_URL), run.getId(), containerId, preferenceManager.getPreference(SystemPreferences.COMMIT_TIMEOUT), run.getDockerImage(), run.getTaskName());
RunInstance instance = run.getInstance();
kubernetesManager.addNodeLabel(instance.getNodeName(), KubernetesConstants.PAUSED_NODE_LABEL, TaskStatus.PAUSED.name());
run.setPodIP(null);
runManager.updatePodIP(run);
runManager.updateServiceUrl(run.getId(), new PipelineRunServiceUrlVO());
Process sshConnection = submitCommandViaSSH(instance.getNodeIP(), pauseRunCommand);
// TODO: change SystemPreferences.COMMIT_TIMEOUT in according to
// f_EPMCMBIBPC-2025_add_lastStatusUpdate_time branche
boolean isFinished = sshConnection.waitFor(preferenceManager.getPreference(SystemPreferences.COMMIT_TIMEOUT), TimeUnit.SECONDS);
if (isFinished && sshConnection.exitValue() == COMMAND_CANNOT_EXECUTE_CODE) {
// TODO: change in according to f_EPMCMBIBPC-2025_add_lastStatusUpdate_time branche
run.setStatus(TaskStatus.RUNNING);
runManager.updatePipelineStatus(run);
kubernetesManager.removeNodeLabel(instance.getNodeName(), KubernetesConstants.PAUSED_NODE_LABEL);
return;
}
Assert.state(sshConnection.exitValue() == 0, messageHelper.getMessage(MessageConstants.ERROR_RUN_PIPELINES_PAUSE_FAILED, run.getId()));
kubernetesManager.deletePod(run.getPodId());
clusterManager.stopInstance(instance.getNodeId(), instance.getAwsRegionId());
kubernetesManager.deleteNode(instance.getNodeName());
run.setStatus(TaskStatus.PAUSED);
runManager.updatePipelineStatus(run);
} catch (Exception e) {
failRunAndTerminateNode(run, e);
throw new IllegalArgumentException(PAUSE_COMMAND_DESCRIPTION, e);
}
}
Aggregations