Skip to content

Commit

Permalink
Revert "fix(e2e): reduce e2e flakiness when a deployment pod restarts"
Browse files Browse the repository at this point in the history
This reverts commit cb1a4bf.

Accidental commit into main
  • Loading branch information
TheSpiritXIII committed May 28, 2024
1 parent cb1a4bf commit 42f1ac3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 39 deletions.
1 change: 0 additions & 1 deletion e2e/deploy/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
15 changes: 15 additions & 0 deletions e2e/kube/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
37 changes: 0 additions & 37 deletions e2e/kube/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
1 change: 0 additions & 1 deletion e2e/ruler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 42f1ac3

Please sign in to comment.