Check both daemonsets before returning non-NotFound lookup error in IsReady

Co-authored-by: kaovilai <11228024+kaovilai@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-08-25 18:19:55 +00:00
committed by GitHub
co-authored by kaovilai
parent 41687279a8
commit ef5375e3e3
2 changed files with 59 additions and 3 deletions
+13 -3
View File
@@ -82,13 +82,17 @@ func KbClientIsRunningInNode(ctx context.Context, namespace string, nodeName str
}
// IsReady checks whether the node-agent daemonset has at least one ready pod
// by inspecting the DaemonSet status.
// by inspecting the DaemonSet status. Both the linux and windows daemonsets
// are checked before returning any non-NotFound lookup error, so that a
// transient error fetching one daemonset does not mask the other daemonset
// being ready.
func IsReady(ctx context.Context, namespace string, crClient ctrlclient.Client) error {
dsLinux := new(appsv1api.DaemonSet)
var lookupErr error
if err := crClient.Get(ctx, ctrlclient.ObjectKey{Namespace: namespace, Name: daemonSet}, dsLinux); err != nil {
dsLinux = nil
if !apierrors.IsNotFound(err) {
return errors.Wrap(err, "failed to get linux node-agent daemonset")
lookupErr = errors.Wrap(err, "failed to get linux node-agent daemonset")
}
}
@@ -96,7 +100,9 @@ func IsReady(ctx context.Context, namespace string, crClient ctrlclient.Client)
if err := crClient.Get(ctx, ctrlclient.ObjectKey{Namespace: namespace, Name: daemonsetWindows}, dsWindows); err != nil {
dsWindows = nil
if !apierrors.IsNotFound(err) {
return errors.Wrap(err, "failed to get windows node-agent daemonset")
if lookupErr == nil {
lookupErr = errors.Wrap(err, "failed to get windows node-agent daemonset")
}
}
}
@@ -108,6 +114,10 @@ func IsReady(ctx context.Context, namespace string, crClient ctrlclient.Client)
return nil
}
if lookupErr != nil {
return lookupErr
}
return errors.New("node-agent is not ready: no ready pods found")
}