Skip to content

Commit b379fcd

Browse files
committed
Revert "feat(sync): Add pod filter using FieldSelector (GoogleContainerTools#9493)"
This reverts commit 08001f6.
1 parent f27e079 commit b379fcd

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

pkg/skaffold/sync/sync.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,16 @@ func Perform(ctx context.Context, image string, files syncMap, cmdFn func(contex
337337

338338
numSynced := 0
339339
for _, ns := range namespaces {
340-
pods, err := client.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{
341-
FieldSelector: fmt.Sprintf("status.phase=%s", v1.PodRunning),
342-
})
340+
pods, err := client.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{})
343341
if err != nil {
344342
return fmt.Errorf("getting pods for namespace %q: %w", ns, err)
345343
}
346344

347345
for _, p := range pods.Items {
346+
if p.Status.Phase != v1.PodRunning {
347+
continue
348+
}
349+
348350
for _, c := range p.Spec.Containers {
349351
if c.Image != image {
350352
continue

pkg/skaffold/sync/sync_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,23 @@ var pod = &v1.Pod{
920920
},
921921
}
922922

923+
var nonRunningPod = &v1.Pod{
924+
ObjectMeta: metav1.ObjectMeta{
925+
Name: "podname",
926+
},
927+
Status: v1.PodStatus{
928+
Phase: v1.PodPending,
929+
},
930+
Spec: v1.PodSpec{
931+
Containers: []v1.Container{
932+
{
933+
Name: "container_name",
934+
Image: "gcr.io/k8s-skaffold:123",
935+
},
936+
},
937+
},
938+
}
939+
923940
func TestPerform(t *testing.T) {
924941
tests := []struct {
925942
description string
@@ -966,6 +983,14 @@ func TestPerform(t *testing.T) {
966983
cmdFn: fakeCmd,
967984
shouldErr: true,
968985
},
986+
{
987+
description: "Skip sync when pod is not running",
988+
image: "gcr.io/k8s-skaffold:123",
989+
files: syncMap{"test.go": {"/test.go"}},
990+
pod: nonRunningPod,
991+
cmdFn: fakeCmd,
992+
shouldErr: true,
993+
},
969994
}
970995
for _, test := range tests {
971996
testutil.Run(t, test.description, func(t *testutil.T) {

0 commit comments

Comments
 (0)