Fail on InvalidImageName (#4007)

This commit is contained in:
Thomas Anderson 2024-08-06 18:07:07 +03:00 committed by GitHub
parent 08b44b95c3
commit c5746ccb50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View file

@ -254,7 +254,7 @@ func (e *kube) WaitStep(ctx context.Context, step *types.Step, taskUUID string)
} }
if pod.Name == podName { if pod.Name == podName {
if isImagePullBackOffState(pod) { if isImagePullBackOffState(pod) || isInvalidImageName(pod) {
finished <- true finished <- true
} }
@ -286,7 +286,7 @@ func (e *kube) WaitStep(ctx context.Context, step *types.Step, taskUUID string)
return nil, err return nil, err
} }
if isImagePullBackOffState(pod) { if isImagePullBackOffState(pod) || isInvalidImageName(pod) {
return nil, fmt.Errorf("could not pull image for pod %s", podName) 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 pod.Name == podName {
if isImagePullBackOffState(pod) { if isImagePullBackOffState(pod) || isInvalidImageName(pod) {
up <- true up <- true
} }
switch pod.Status.Phase { switch pod.Status.Phase {

View file

@ -65,6 +65,18 @@ func isImagePullBackOffState(pod *v1.Pod) bool {
return false 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. // getClientOutOfCluster returns a k8s client set to the request from outside of cluster.
func getClientOutOfCluster() (kubernetes.Interface, error) { func getClientOutOfCluster() (kubernetes.Interface, error) {
kubeConfigPath := os.Getenv("KUBECONFIG") // cspell:words KUBECONFIG kubeConfigPath := os.Getenv("KUBECONFIG") // cspell:words KUBECONFIG