Skip to content

Commit

Permalink
Record error on job pod image pull failure
Browse files Browse the repository at this point in the history
  • Loading branch information
rjeberhard committed Aug 20, 2024
1 parent cdeb0a1 commit 536e9b5
Showing 1 changed file with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,12 @@ public Result onSuccess(Packet packet, KubernetesApiResponse<V1PodList> callResp
if (jobPod == null) {
return doContinueListOrNext(callResponse, packet, processIntrospectorPodLog(getNext()));
} else if (hasImagePullError(jobPod) || initContainersHaveImagePullError(jobPod)) {
return doNext(cleanUpAndReintrospect(getNext()), packet);

String reason = getImagePullError(jobPod);
V1Job domainIntrospectorJob = packet.getValue(DOMAIN_INTROSPECTOR_JOB);
return doNext(Step.chain(
createIntrospectionFailureSteps(reason, domainIntrospectorJob),
cleanUpAndReintrospect(getNext())), packet);
} else if (isJobPodTimedOut(jobPod)) {
// process job pod timed out same way as job timed out, which is to
// terminate current fiber
Expand Down Expand Up @@ -903,13 +908,33 @@ private boolean initContainersHaveImagePullError(V1Pod pod) {
.map(V1ContainerStateWaiting::getReason)
.anyMatch(IntrospectionStatus::isImagePullError))
.orElse(false);

}

private List<V1ContainerStatus> getInitContainerStatuses(V1Pod pod) {
return Optional.ofNullable(pod.getStatus()).map(V1PodStatus::getInitContainerStatuses).orElse(null);
}

private String getImagePullError(V1Pod pod) {
String reason = getJobPodContainerWaitingReason(pod);
if (!IntrospectionStatus.isImagePullError(reason)) {

List<V1ContainerStatus> statuses = getInitContainerStatuses(pod);
if (statuses != null) {
for (V1ContainerStatus status : statuses) {
if (status != null && status.getState() != null) {
V1ContainerStateWaiting waiting = status.getState().getWaiting();
if (waiting != null && waiting.getReason() != null) {
if (IntrospectionStatus.isImagePullError(waiting.getReason())) {
reason = waiting.getReason();
}
}
}
}
}
}
return reason;
}

private void recordJobPod(Packet packet, V1Pod jobPod) {
packet.put(ProcessingConstants.JOB_POD, jobPod);
}
Expand Down

0 comments on commit 536e9b5

Please sign in to comment.