Skip to content

Commit

Permalink
fix: interface conversion error for pod event (#6863)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsquared94 authored Nov 16, 2021
1 parent 519fb58 commit d2e73f3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
5 changes: 4 additions & 1 deletion pkg/skaffold/kubernetes/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ func isPodSucceeded(podName string) func(event *watch.Event) (bool, error) {
if event.Object == nil {
return false, nil
}
pod := event.Object.(*v1.Pod)
pod, isPod := event.Object.(*v1.Pod)
if !isPod {
return false, nil
}
if pod.Name != podName {
return false, nil
}
Expand Down
22 changes: 17 additions & 5 deletions pkg/skaffold/kubernetes/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch"
fakekubeclientset "k8s.io/client-go/kubernetes/fake"

Expand Down Expand Up @@ -49,6 +50,10 @@ func TestWaitForPodSucceeded(t *testing.T) {
timeout: 10 * time.Millisecond,
phases: []v1.PodPhase{v1.PodRunning, v1.PodRunning, v1.PodRunning, v1.PodRunning, v1.PodRunning, v1.PodRunning},
shouldErr: true,
}, {
description: "resilient to network issues",
timeout: 1 * time.Second,
phases: []v1.PodPhase{v1.PodRunning, "", "", v1.PodSucceeded},
},
}

Expand All @@ -70,11 +75,18 @@ func TestWaitForPodSucceeded(t *testing.T) {
if fakeWatcher.IsStopped() {
break
}
fakeWatcher.Modify(&v1.Pod{
Status: v1.PodStatus{
Phase: phase,
},
})
switch phase {
case v1.PodPending, v1.PodRunning, v1.PodFailed, v1.PodSucceeded, v1.PodUnknown:
fakeWatcher.Modify(&v1.Pod{
Status: v1.PodStatus{
Phase: phase,
},
})
default:
fakeWatcher.Modify(&metav1.Status{
Status: "Failure",
})
}
time.Sleep(1 * time.Millisecond)
}
err := <-errChan
Expand Down

0 comments on commit d2e73f3

Please sign in to comment.