use of com.google.cloud.dataproc.v1beta2.JobStatus in project halyard by spinnaker.
the class KubernetesV2Utils method exists.
private static boolean exists(KubernetesAccount account, String namespace, String kind, String name) {
log.info("Checking for " + kind + "/" + name);
List<String> command = kubectlPrefix(account);
if (StringUtils.isNotEmpty(namespace)) {
command.add("-n");
command.add(namespace);
}
command.add("get");
command.add(kind);
command.add(name);
JobRequest request = new JobRequest().setTokenizedCommand(command);
String jobId = DaemonTaskHandler.getJobExecutor().startJob(request);
JobStatus status;
try {
status = DaemonTaskHandler.getJobExecutor().backoffWait(jobId);
} catch (InterruptedException e) {
throw new DaemonTaskInterrupted(e);
}
if (status.getState() != JobStatus.State.COMPLETED) {
throw new HalException(Problem.Severity.FATAL, String.join("\n", "Unterminated check for " + kind + "/" + name + " in " + namespace, status.getStdErr(), status.getStdOut()));
}
if (status.getResult() == JobStatus.Result.SUCCESS) {
return true;
} else if (status.getStdErr().contains("NotFound")) {
return false;
} else {
throw new HalException(Problem.Severity.FATAL, String.join("\n", "Failed check for " + kind + "/" + name + " in " + namespace, status.getStdErr(), status.getStdOut()));
}
}
use of com.google.cloud.dataproc.v1beta2.JobStatus in project halyard by spinnaker.
the class KubernetesV1RedisService method connectToPrimaryService.
@Override
public Jedis connectToPrimaryService(AccountDeploymentDetails<KubernetesAccount> details, SpinnakerRuntimeSettings runtimeSettings) {
ServiceSettings settings = runtimeSettings.getServiceSettings(this);
List<String> command = Arrays.stream(connectCommand(details, runtimeSettings).split(" ")).collect(Collectors.toList());
JobRequest request = new JobRequest().setTokenizedCommand(command);
String jobId = getJobExecutor().startJob(request);
// Wait for the proxy to spin up.
DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(5));
JobStatus status = getJobExecutor().updateJob(jobId);
// This should be a long-running job.
if (status.getState() == JobStatus.State.COMPLETED) {
throw new HalException(Problem.Severity.FATAL, "Unable to establish a proxy against Redis:\n" + status.getStdOut() + "\n" + status.getStdErr());
}
return new Jedis("localhost", settings.getPort());
}
use of com.google.cloud.dataproc.v1beta2.JobStatus in project strimzi by strimzi.
the class JobUtils method waitForJobRunning.
/**
* Wait for specific Job Running active status
* @param jobName job name
* @param namespace namespace
*/
public static boolean waitForJobRunning(String jobName, String namespace) {
LOGGER.info("Waiting for job: {} will be in active state", jobName);
TestUtils.waitFor("job active", Constants.GLOBAL_POLL_INTERVAL, ResourceOperation.getTimeoutForResourceReadiness(Constants.JOB), () -> {
JobStatus jb = kubeClient().namespace(namespace).getJobStatus(jobName);
return jb.getActive() > 0;
});
return true;
}
use of com.google.cloud.dataproc.v1beta2.JobStatus in project halyard by spinnaker.
the class KubernetesAccountValidator method ensureKubectlExists.
public void ensureKubectlExists(ConfigProblemSetBuilder p) {
JobExecutor jobExecutor = DaemonTaskHandler.getJobExecutor();
JobRequest request = new JobRequest().setTokenizedCommand(Collections.singletonList("kubectl")).setTimeoutMillis(TimeUnit.SECONDS.toMillis(10));
JobStatus status;
try {
status = jobExecutor.backoffWait(jobExecutor.startJob(request));
} catch (InterruptedException e) {
throw new DaemonTaskInterrupted(e);
}
if (status.getResult() != JobStatus.Result.SUCCESS) {
p.addProblem(FATAL, String.join(" ", "`kubectl` not installed, or can't be found by Halyard. It is needed for", "opening connections to your Kubernetes cluster to send commands to the Spinnaker deployment running there.")).setRemediation(String.join(" ", "Visit https://kubernetes.io/docs/tasks/kubectl/install/.", "If you've already installed kubectl via gcloud, it's possible updates to your $PATH aren't visible to Halyard. ", "You might have to restart Halyard for it to pick up the new $PATH."));
}
}
use of com.google.cloud.dataproc.v1beta2.JobStatus in project halyard by spinnaker.
the class AbstractRemoteActionCommand method runRemoteAction.
protected void runRemoteAction(OperationHandler<RemoteAction> operation) {
RemoteAction action = operation.get();
String scriptPath = action.getScriptPath();
if (StringUtils.isEmpty(scriptPath)) {
return;
}
boolean shouldRun;
if (autoRun == null) {
shouldRun = action.isAutoRun();
} else {
shouldRun = action.isAutoRun() && autoRun;
}
if (!shouldRun) {
AnsiStoryBuilder storyBuilder = new AnsiStoryBuilder();
AnsiParagraphBuilder paragraphBuilder = storyBuilder.addParagraph();
paragraphBuilder.addSnippet(action.getScriptDescription());
storyBuilder.addNewline();
paragraphBuilder = storyBuilder.addParagraph();
paragraphBuilder.addSnippet("Please run the following script:");
storyBuilder.addNewline();
paragraphBuilder = storyBuilder.addParagraph();
paragraphBuilder.addSnippet(action.getScriptPath()).addStyle(AnsiStyle.UNDERLINE);
AnsiUi.raw(storyBuilder.toString());
} else {
List<String> command = new ArrayList<>();
command.add(scriptPath);
JobRequest request = new JobRequest().setTokenizedCommand(command);
JobExecutor executor = getJobExecutor();
String jobId = executor.startJobFromStandardStreams(request);
JobStatus status = null;
try {
status = executor.backoffWait(jobId);
} catch (InterruptedException e) {
AnsiUi.failure("Interrupted.");
System.exit(1);
}
if (status.getResult() != JobStatus.Result.SUCCESS) {
AnsiUi.error("Error encountered running script. See above output for more details.");
System.exit(1);
}
}
}
Aggregations