Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
fix/feature: #4802
  • Loading branch information
yuzp1996 committed May 8, 2022
1 parent f1ff83f commit 91f2482
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/pod/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const (
// to resource constraints on the node
ReasonExceededNodeResources = "ExceededNodeResources"

ErrImagePull = "ErrImagePull"

// ReasonCreateContainerConfigError indicates that the TaskRun failed to create a pod due to
// config error of container
ReasonCreateContainerConfigError = "CreateContainerConfigError"
Expand Down Expand Up @@ -314,6 +316,8 @@ func updateIncompleteTaskRunStatus(trs *v1beta1.TaskRunStatus, pod *corev1.Pod)
markStatusRunning(trs, ReasonExceededNodeResources, "TaskRun Pod exceeded available resources")
case isPodHitConfigError(pod):
markStatusFailure(trs, ReasonCreateContainerConfigError, "Failed to create pod due to config error")
case isImageError(pod):
markStatusRunning(trs, ErrImagePull, ErrImagePull)
default:
markStatusRunning(trs, ReasonPending, getWaitingMessage(pod))
}
Expand Down Expand Up @@ -408,6 +412,16 @@ func isPodHitConfigError(pod *corev1.Pod) bool {
return false
}

// isImageError returns true if the Pod's status undicates there are config error raised
func isImageError(pod *corev1.Pod) bool {
for _, containerStatus := range pod.Status.ContainerStatuses {
if containerStatus.State.Waiting != nil && containerStatus.State.Waiting.Reason == "ErrImagePull" {
return true
}
}
return false
}

func getWaitingMessage(pod *corev1.Pod) string {
// First, try to surface reason for pending/unknown about the actual build step.
for _, status := range pod.Status.ContainerStatuses {
Expand Down

0 comments on commit 91f2482

Please sign in to comment.