Skip to content

Commit 3ec8437

Browse files
committed
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.
1 parent d9c46d8 commit 3ec8437

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/e2e/framework/daemonset/fixtures.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,16 @@ func checkDaemonPodStateOnNodes(ctx context.Context, c clientset.Interface, ds *
139139
return len(nodesToPodCount) == len(nodeNames), nil
140140
}
141141

142+
// CheckDaemonStatus returns an error if not all desired pods are scheduled or
143+
// not all of them are ready.
142144
func CheckDaemonStatus(ctx context.Context, f *framework.Framework, dsName string) error {
143145
ds, err := f.ClientSet.AppsV1().DaemonSets(f.Namespace.Name).Get(ctx, dsName, metav1.GetOptions{})
144146
if err != nil {
145147
return err
146148
}
147149
desired, scheduled, ready := ds.Status.DesiredNumberScheduled, ds.Status.CurrentNumberScheduled, ds.Status.NumberReady
148-
if desired != scheduled && desired != ready {
149-
return fmt.Errorf("error in daemon status. DesiredScheduled: %d, CurrentScheduled: %d, Ready: %d", desired, scheduled, ready)
150+
if desired == scheduled && scheduled == ready {
151+
return nil
150152
}
151-
return nil
153+
return fmt.Errorf("error in daemon status. DesiredScheduled: %d, CurrentScheduled: %d, Ready: %d", desired, scheduled, ready)
152154
}

0 commit comments

Comments
 (0)