Search in sources :

Example 21 with JobStatus

use of com.google.cloud.dataproc.v1beta2.JobStatus in project halyard by spinnaker.

the class VaultService method publishSecret.

public void publishSecret(DeploymentConfiguration deploymentConfiguration, String name, String contents) {
    String vaultAddress = deploymentConfiguration.getDeploymentEnvironment().getVault().getAddress();
    String encodedContents = Base64.getEncoder().encodeToString(contents.getBytes());
    String secretName = vaultSecretPrefix + name;
    List<String> command = new ArrayList<>();
    command.add("vault");
    command.add("write");
    command.add("--address");
    command.add(vaultAddress);
    command.add(secretName);
    command.add(encodedContents);
    JobRequest request = new JobRequest().setTokenizedCommand(command).setTimeoutMillis(TimeUnit.SECONDS.toMillis(vaultTimeoutSeconds));
    String id = jobExecutor.startJob(request);
    DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(5));
    JobStatus status = jobExecutor.updateJob(id);
    if (!status.getResult().equals(JobStatus.Result.SUCCESS)) {
        throw new HalException(Problem.Severity.FATAL, "Failed to publish secret " + name + ": " + status.getStdOut() + status.getStdErr());
    }
}
Also used : JobStatus(com.netflix.spinnaker.halyard.core.job.v1.JobStatus) JobRequest(com.netflix.spinnaker.halyard.core.job.v1.JobRequest) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) ArrayList(java.util.ArrayList)

Example 22 with JobStatus

use of com.google.cloud.dataproc.v1beta2.JobStatus in project strimzi-kafka-operator 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;
}
Also used : JobStatus(io.fabric8.kubernetes.api.model.batch.v1.JobStatus)

Example 23 with JobStatus

use of com.google.cloud.dataproc.v1beta2.JobStatus in project pipelite by enasequence.

the class KubernetesExecutorTest method describeJobsStateError.

@Test
public void describeJobsStateError() {
    JobStatus jobStatus = new JobStatus();
    JobCondition jobCondition = new JobCondition();
    jobCondition.setType("Failed");
    jobCondition.setStatus("true");
    jobStatus.setConditions(Arrays.asList(jobCondition));
    assertThat(KubernetesExecutor.describeJobsResultFromStatus(jobStatus).isError()).isTrue();
}
Also used : JobStatus(io.fabric8.kubernetes.api.model.batch.v1.JobStatus) JobCondition(io.fabric8.kubernetes.api.model.batch.v1.JobCondition) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 24 with JobStatus

use of com.google.cloud.dataproc.v1beta2.JobStatus in project pipelite by enasequence.

the class KubernetesExecutorTest method describeJobsStateActive.

@Test
public void describeJobsStateActive() {
    JobStatus jobStatus = new JobStatus();
    assertThat(KubernetesExecutor.describeJobsResultFromStatus(jobStatus).isActive()).isTrue();
    jobStatus.setActive(1);
    assertThat(KubernetesExecutor.describeJobsResultFromStatus(jobStatus).isActive()).isTrue();
}
Also used : JobStatus(io.fabric8.kubernetes.api.model.batch.v1.JobStatus) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

JobStatus (com.netflix.spinnaker.halyard.core.job.v1.JobStatus)18 JobRequest (com.netflix.spinnaker.halyard.core.job.v1.JobRequest)17 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)16 DaemonTaskInterrupted (com.netflix.spinnaker.halyard.core.tasks.v1.DaemonTaskInterrupted)11 JobStatus (io.fabric8.kubernetes.api.model.batch.v1.JobStatus)6 JobExecutor (com.netflix.spinnaker.halyard.core.job.v1.JobExecutor)5 ArrayList (java.util.ArrayList)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Test (org.junit.jupiter.api.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)2 JobCondition (io.fabric8.kubernetes.api.model.batch.v1.JobCondition)2 File (java.io.File)2 IOException (java.io.IOException)2 AnsiParagraphBuilder (com.netflix.spinnaker.halyard.cli.ui.v1.AnsiParagraphBuilder)1 AnsiStoryBuilder (com.netflix.spinnaker.halyard.cli.ui.v1.AnsiStoryBuilder)1 KubernetesAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount)1 RemoteAction (com.netflix.spinnaker.halyard.core.RemoteAction)1 HasServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.HasServiceSettings)1