use of io.fabric8.kubernetes.api.model.batch.v1.JobCondition in project pipelite by enasequence.
the class KubernetesExecutorTest method describeJobsStateSuccess.
@Test
public void describeJobsStateSuccess() {
JobStatus jobStatus = new JobStatus();
jobStatus.setCompletionTime("test");
assertThat(KubernetesExecutor.describeJobsResultFromStatus(jobStatus).isSuccess()).isTrue();
jobStatus = new JobStatus();
JobCondition jobCondition = new JobCondition();
jobCondition.setType("Complete");
jobCondition.setStatus("true");
jobStatus.setConditions(Arrays.asList(jobCondition));
assertThat(KubernetesExecutor.describeJobsResultFromStatus(jobStatus).isSuccess()).isTrue();
}
use of io.fabric8.kubernetes.api.model.batch.v1.JobCondition in project strimzi-kafka-operator by strimzi.
the class JobUtils method logCurrentJobStatus.
/**
* Log actual status of Job with pods.
* @param jobName - name of the job, for which we should scrape status
* @param namespace - namespace/project where is job running
*/
public static void logCurrentJobStatus(String jobName, String namespace) {
Job currentJob = kubeClient().getJob(namespace, jobName);
if (currentJob != null && currentJob.getStatus() != null) {
List<String> log = new ArrayList<>(asList(Constants.JOB, " status:\n"));
List<JobCondition> conditions = currentJob.getStatus().getConditions();
log.add("\tActive: " + currentJob.getStatus().getActive());
log.add("\n\tFailed: " + currentJob.getStatus().getFailed());
log.add("\n\tReady: " + currentJob.getStatus().getReady());
log.add("\n\tSucceeded: " + currentJob.getStatus().getSucceeded());
if (conditions != null) {
List<String> conditionList = new ArrayList<>();
for (JobCondition condition : conditions) {
if (condition.getMessage() != null) {
conditionList.add("\t\tType: " + condition.getType() + "\n");
conditionList.add("\t\tMessage: " + condition.getMessage() + "\n");
}
}
if (!conditionList.isEmpty()) {
log.add("\n\tConditions:\n");
log.addAll(conditionList);
}
}
log.add("\n\nPods with conditions and messages:\n\n");
for (Pod pod : kubeClient().namespace(currentJob.getMetadata().getNamespace()).listPodsByPrefixInName(jobName)) {
log.add(pod.getMetadata().getName() + ":");
List<String> podConditions = new ArrayList<>();
for (PodCondition podCondition : pod.getStatus().getConditions()) {
if (podCondition.getMessage() != null) {
podConditions.add("\n\tType: " + podCondition.getType() + "\n");
podConditions.add("\tMessage: " + podCondition.getMessage() + "\n");
}
}
if (podConditions.isEmpty()) {
log.add("\n\t<EMPTY>");
} else {
log.addAll(podConditions);
}
log.add("\n\n");
}
LOGGER.info("{}", String.join("", log).strip());
}
}
use of io.fabric8.kubernetes.api.model.batch.v1.JobCondition in project strimzi by strimzi.
the class JobUtils method logCurrentJobStatus.
/**
* Log actual status of Job with pods.
* @param jobName - name of the job, for which we should scrape status
* @param namespace - namespace/project where is job running
*/
public static void logCurrentJobStatus(String jobName, String namespace) {
Job currentJob = kubeClient().getJob(namespace, jobName);
if (currentJob != null && currentJob.getStatus() != null) {
List<String> log = new ArrayList<>(asList(Constants.JOB, " status:\n"));
List<JobCondition> conditions = currentJob.getStatus().getConditions();
log.add("\tActive: " + currentJob.getStatus().getActive());
log.add("\n\tFailed: " + currentJob.getStatus().getFailed());
log.add("\n\tReady: " + currentJob.getStatus().getReady());
log.add("\n\tSucceeded: " + currentJob.getStatus().getSucceeded());
if (conditions != null) {
List<String> conditionList = new ArrayList<>();
for (JobCondition condition : conditions) {
if (condition.getMessage() != null) {
conditionList.add("\t\tType: " + condition.getType() + "\n");
conditionList.add("\t\tMessage: " + condition.getMessage() + "\n");
}
}
if (!conditionList.isEmpty()) {
log.add("\n\tConditions:\n");
log.addAll(conditionList);
}
}
log.add("\n\nPods with conditions and messages:\n\n");
for (Pod pod : kubeClient().namespace(currentJob.getMetadata().getNamespace()).listPodsByPrefixInName(jobName)) {
log.add(pod.getMetadata().getName() + ":");
List<String> podConditions = new ArrayList<>();
for (PodCondition podCondition : pod.getStatus().getConditions()) {
if (podCondition.getMessage() != null) {
podConditions.add("\n\tType: " + podCondition.getType() + "\n");
podConditions.add("\tMessage: " + podCondition.getMessage() + "\n");
}
}
if (podConditions.isEmpty()) {
log.add("\n\t<EMPTY>");
} else {
log.addAll(podConditions);
}
log.add("\n\n");
}
LOGGER.info("{}", String.join("", log).strip());
}
}
use of io.fabric8.kubernetes.api.model.batch.v1.JobCondition 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();
}
Aggregations