mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-13 20:51:41 +00:00
Fail on InvalidImageName (#4007)
This commit is contained in:
parent
08b44b95c3
commit
c5746ccb50
2 changed files with 15 additions and 3 deletions
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue