From 7a455545f009e90ce1e62da331a5aa64057ff148 Mon Sep 17 00:00:00 2001 From: Carter McKinnon Date: Tue, 31 Oct 2023 20:53:09 -0700 Subject: [PATCH] Add conditions.DaemonSetReady --- klient/wait/conditions/conditions.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/klient/wait/conditions/conditions.go b/klient/wait/conditions/conditions.go index 6e81962e..e7d04927 100644 --- a/klient/wait/conditions/conditions.go +++ b/klient/wait/conditions/conditions.go @@ -303,3 +303,17 @@ func (c *Condition) DeploymentAvailable(name, namespace string) apimachinerywait v1.ConditionTrue, ) } + +// DaemonSetReady is a helper function used to check if a daemonset's pods are scheduled and ready +func (c *Condition) DaemonSetReady(daemonset k8s.Object) apimachinerywait.ConditionWithContextFunc { + return func(ctx context.Context) (done bool, err error) { + if err := c.resources.Get(ctx, daemonset.GetName(), daemonset.GetNamespace(), daemonset); err != nil { + return false, err + } + status := daemonset.(*appsv1.DaemonSet).Status + if status.NumberReady == status.DesiredNumberScheduled && status.NumberUnavailable == 0 { + done = true + } + return + } +}