Skip to content

Commit

Permalink
test: Skip looking for unschedulable pods when running with envtest. (#…
Browse files Browse the repository at this point in the history
…867)

We have seen flakiness due to the pods being deleted so fast after
manually marking them unschedulable, that the ListPods never gets to see
the unschedulable pods.
  • Loading branch information
SaaldjorMike authored Oct 28, 2024
1 parent 81939dc commit 9355f5e
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions controllers/suite/clusters/humiocluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,22 +354,24 @@ var _ = Describe("HumioCluster Controller", func() {

ensurePodsGoPending(ctx, controllers.NewHumioNodeManagerFromHumioCluster(&updatedHumioCluster), 2, 1)

Eventually(func() int {
var pendingPodsCount int
updatedClusterPods, _ = kubernetes.ListPods(ctx, k8sClient, updatedHumioCluster.Namespace, controllers.NewHumioNodeManagerFromHumioCluster(&updatedHumioCluster).GetPodLabels())
for _, pod := range updatedClusterPods {
if pod.Status.Phase == corev1.PodPending {
for _, condition := range pod.Status.Conditions {
if condition.Type == corev1.PodScheduled {
if condition.Status == corev1.ConditionFalse && condition.Reason == controllers.PodConditionReasonUnschedulable {
pendingPodsCount++
if !helpers.UseEnvtest() {
Eventually(func() int {
var pendingPodsCount int
updatedClusterPods, _ = kubernetes.ListPods(ctx, k8sClient, updatedHumioCluster.Namespace, controllers.NewHumioNodeManagerFromHumioCluster(&updatedHumioCluster).GetPodLabels())
for _, pod := range updatedClusterPods {
if pod.Status.Phase == corev1.PodPending {
for _, condition := range pod.Status.Conditions {
if condition.Type == corev1.PodScheduled {
if condition.Status == corev1.ConditionFalse && condition.Reason == controllers.PodConditionReasonUnschedulable {
pendingPodsCount++
}
}
}
}
}
}
return pendingPodsCount
}, testTimeout, 250*time.Millisecond).Should(Equal(1))
return pendingPodsCount
}, testTimeout, 250*time.Millisecond).Should(Equal(1))
}

suite.UsingClusterBy(key.Name, "Updating the cluster resources successfully with working affinity")
Eventually(func() error {
Expand Down

0 comments on commit 9355f5e

Please sign in to comment.