diff --git a/pipeline/backend/kubernetes/kubernetes.go b/pipeline/backend/kubernetes/kubernetes.go index 003656896..dadf913c5 100644 --- a/pipeline/backend/kubernetes/kubernetes.go +++ b/pipeline/backend/kubernetes/kubernetes.go @@ -254,7 +254,7 @@ func (e *kube) WaitStep(ctx context.Context, step *types.Step, taskUUID string) } if pod.Name == podName { - if isImagePullBackOffState(pod) { + if isImagePullBackOffState(pod) || isInvalidImageName(pod) { finished <- true } @@ -286,7 +286,7 @@ func (e *kube) WaitStep(ctx context.Context, step *types.Step, taskUUID string) return nil, err } - if isImagePullBackOffState(pod) { + if isImagePullBackOffState(pod) || isInvalidImageName(pod) { return nil, fmt.Errorf("could not pull image for pod %s", podName) } @@ -330,7 +330,7 @@ func (e *kube) TailStep(ctx context.Context, step *types.Step, taskUUID string) } if pod.Name == podName { - if isImagePullBackOffState(pod) { + if isImagePullBackOffState(pod) || isInvalidImageName(pod) { up <- true } switch pod.Status.Phase { diff --git a/pipeline/backend/kubernetes/utils.go b/pipeline/backend/kubernetes/utils.go index 1393c423b..ec601bccc 100644 --- a/pipeline/backend/kubernetes/utils.go +++ b/pipeline/backend/kubernetes/utils.go @@ -65,6 +65,18 @@ func isImagePullBackOffState(pod *v1.Pod) bool { return false } +func isInvalidImageName(pod *v1.Pod) bool { + for _, containerState := range pod.Status.ContainerStatuses { + if containerState.State.Waiting != nil { + if containerState.State.Waiting.Reason == "InvalidImageName" { + return true + } + } + } + + return false +} + // getClientOutOfCluster returns a k8s client set to the request from outside of cluster. func getClientOutOfCluster() (kubernetes.Interface, error) { kubeConfigPath := os.Getenv("KUBECONFIG") // cspell:words KUBECONFIG