Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#344 from cartermckinnon/daemonset-…
Browse files Browse the repository at this point in the history
…ready-condition

Add conditions.DaemonSetReady
  • Loading branch information
k8s-ci-robot authored Nov 8, 2023
2 parents 365c4a4 + 7a45554 commit b4b509b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions klient/wait/conditions/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit b4b509b

Please sign in to comment.