Skip to content

Commit

Permalink
e2e daemonset: stronger health check of DaemonSet status
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pohly committed Oct 11, 2024
1 parent d9c46d8 commit 3ec8437
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/e2e/framework/daemonset/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 3ec8437

Please sign in to comment.