From 3ec84373c143da1e41f564188cf8a3234f9be2f7 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Thu, 10 Oct 2024 19:37:28 +0200 Subject: [PATCH] e2e daemonset: stronger health check of DaemonSet status The error was only generated if both checks (generated pods and ready pods) failed. This looks like a logic error, failing if either of those isn't matching expectations seems better. --- test/e2e/framework/daemonset/fixtures.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/e2e/framework/daemonset/fixtures.go b/test/e2e/framework/daemonset/fixtures.go index 1bc35f2e7c4..ed725010224 100644 --- a/test/e2e/framework/daemonset/fixtures.go +++ b/test/e2e/framework/daemonset/fixtures.go @@ -139,14 +139,16 @@ func checkDaemonPodStateOnNodes(ctx context.Context, c clientset.Interface, ds * return len(nodesToPodCount) == len(nodeNames), nil } +// CheckDaemonStatus returns an error if not all desired pods are scheduled or +// not all of them are ready. func CheckDaemonStatus(ctx context.Context, f *framework.Framework, dsName string) error { ds, err := f.ClientSet.AppsV1().DaemonSets(f.Namespace.Name).Get(ctx, dsName, metav1.GetOptions{}) if err != nil { return err } desired, scheduled, ready := ds.Status.DesiredNumberScheduled, ds.Status.CurrentNumberScheduled, ds.Status.NumberReady - if desired != scheduled && desired != ready { - return fmt.Errorf("error in daemon status. DesiredScheduled: %d, CurrentScheduled: %d, Ready: %d", desired, scheduled, ready) + if desired == scheduled && scheduled == ready { + return nil } - return nil + return fmt.Errorf("error in daemon status. DesiredScheduled: %d, CurrentScheduled: %d, Ready: %d", desired, scheduled, ready) }