diff --git a/e2e/deploy/operator.go b/e2e/deploy/operator.go index d4d82a542a..420600d625 100644 --- a/e2e/deploy/operator.go +++ b/e2e/deploy/operator.go @@ -44,7 +44,6 @@ func operatorPod(ctx context.Context, kubeClient client.Client, operatorNamespac if err != nil { return nil, err } - podList = kube.PodsReady(podList) if len(podList) != 1 { return nil, fmt.Errorf("expected 1 pod, found %d", len(podList)) } diff --git a/e2e/kube/debug.go b/e2e/kube/debug.go index 1235b623a3..ea659f561a 100644 --- a/e2e/kube/debug.go +++ b/e2e/kube/debug.go @@ -23,6 +23,7 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/rest" @@ -138,3 +139,17 @@ func workloadPods(ctx context.Context, kubeClient client.Client, o client.Object return nil, errors.New("invalid object type") } } + +func podsFromSelector(ctx context.Context, kubeClient client.Client, ps *metav1.LabelSelector) ([]corev1.Pod, error) { + selector, err := metav1.LabelSelectorAsSelector(ps) + if err != nil { + return nil, err + } + podList := &corev1.PodList{} + if err := kubeClient.List(ctx, podList, &client.ListOptions{ + LabelSelector: selector, + }); err != nil { + return nil, err + } + return podList.Items, nil +} diff --git a/e2e/kube/pod.go b/e2e/kube/pod.go index 8e5f41c9f8..1fd670afbd 100644 --- a/e2e/kube/pod.go +++ b/e2e/kube/pod.go @@ -48,29 +48,6 @@ func PodLogs(ctx context.Context, restConfig *rest.Config, namespace, name, cont return builder.String(), nil } -// PodsReady filters the given pod list, returning only ready pods. -func PodsReady(pods []corev1.Pod) []corev1.Pod { - var podsFiltered []corev1.Pod - for _, pod := range pods { - if isPodReady(&pod) { - podsFiltered = append(podsFiltered, pod) - } - } - return podsFiltered -} - -func isPodReady(pod *corev1.Pod) bool { - if len(pod.Spec.Containers) != len(pod.Status.ContainerStatuses) { - return false - } - for _, container := range pod.Status.ContainerStatuses { - if !container.Ready { - return false - } - } - return true -} - func waitForPodContainerReady(ctx context.Context, kubeClient client.Client, pod *corev1.Pod, container string) error { return waitForResourceReady(ctx, kubeClient, pod, func(pod *corev1.Pod) error { return isPodContainerReady(pod, container) @@ -129,17 +106,3 @@ func podByAddr(ctx context.Context, kubeClient client.Client, addr *net.TCPAddr) key := client.ObjectKeyFromObject(pod) return nil, "", fmt.Errorf("unable to find port %d in pod %s", addr.Port, key) } - -func podsFromSelector(ctx context.Context, kubeClient client.Client, ps *metav1.LabelSelector) ([]corev1.Pod, error) { - selector, err := metav1.LabelSelectorAsSelector(ps) - if err != nil { - return nil, err - } - podList := &corev1.PodList{} - if err := kubeClient.List(ctx, podList, &client.ListOptions{ - LabelSelector: selector, - }); err != nil { - return nil, err - } - return podList.Items, nil -} diff --git a/e2e/ruler_test.go b/e2e/ruler_test.go index a559c38f9f..d48e8912d5 100644 --- a/e2e/ruler_test.go +++ b/e2e/ruler_test.go @@ -719,7 +719,6 @@ func ruleEvaluatorPod(ctx context.Context, kubeClient client.Client, namespace s if err != nil { return nil, err } - podList = kube.PodsReady(podList) if len(podList) != 1 { return nil, fmt.Errorf("expected 1 pod, found %d", len(podList)) }