check-operator: optionally skip not-Ready nodes in the Agent upgrade check #3686
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3686"
general
weight: 0.35
levan-m
What does this PR do?
Adds an opt-in setting to
check-operator upgrade,AGENT_SKIP_NOT_READY_NODES(defaultfalse). When the Agent threshold is not reached, the check stops counting not-Ready nodes whose Agent pod is out of date.On some clusters a few % of nodes go
Unknown(dead kubelet). Their old Agent pod staysTerminatingforever, so today the check waits until its 2h timeout. On mudkip-d it ran 46 min for this reason (evidence).Alternative to #3650, with the same goal and a simpler structure.
| Variable | Default | Effect |
|---|---|---|
|
AGENT_SKIP_NOT_READY_NODES|false| Turns the discount on. ||
AGENT_SKIP_NOT_READY_MAX_PCT|10| The most % of the Agent nodes that can be skipped. Above it, nothing is skipped (more likely an outage). |New permissions, only with the setting on:
listonpodsanddaemonsetsin the DatadogAgent namespace, andlistonnodes(ClusterRole). The hook RBAC lives in the chart, not in this repo.Review guide
All logic is in
cmd/check-operator/upgrade/upgrade.go. Read in this order:1.
isAgentDoneSkippingNotReadyNodes: entry point. It runs the plain check first, then the discount. Errors wrappingerrNoDiscountare normal "not skipping" outcomes, logged as one line. Other errors are logged as errors. Both fall back to the plain threshold.2.
getNotReadyNodeDiscount: one call per step.-
getSkipBoundson the DatadogAgent status: no API call while skipping cannot help.-
getAgentDaemonSets: sums the live DaemonSet status. The DatadogAgent status can lag behind it.-
getSkipBoundsagain, on the live numbers.-
getAgentPods,getNodes: two Lists from the API server cache.3.
computeNotReadyNodeDiscount: pure function, holds the counting rules.A node is skipped only if all of these hold:
| Rule | Why |
|---|---|
| Node not Ready | The target case |
| Exactly one Agent pod of that DaemonSet on it, out of date (generation and revision hash) | The status judges a node by its oldest pod. With
maxSurge: 0there is one pod, and nodes with several pods are never skipped (safe side) || The DaemonSet's current revision hash is known | Otherwise a reverted pod that the status counts as updated could be skipped |
| No DaemonSet is deleting or has
observedGenerationbehind | The live status must match the pods || Each DaemonSet's discount is reduced by its
numberMisscheduled(not below 0) | Misscheduled nodes (e.g. after a DAP change) are not inCurrent, so they must not be subtracted again || The skipped count is between the fewest needed to pass and the
MAX_PCTcap | No discount that would not change the result, and none during an outage |Known limits: surge rollouts do not benefit. Skipping only helps if the Agent tolerates the
not-ready/unreachableNoScheduletaints (production Agents useoperator: Exists); otherwise the status already leaves these nodes out. With the defaults, the check can pass with up to about 14.5% of nodes out of date: 10% skipped, plus 5% of the rest.Describe your test plan
Runend to end (setting off, setting on, a DaemonSet status behind its spec, live status behind the DatadogAgent status, a misscheduled node). Removing any single rule makes a test fail.<details>
<summary>How to reproduce on a 5-node kind cluster</summary>
Goal: prove the upgrade check skips only not-Ready nodes that hold an out-of-date Agent pod, and that
each safety limit (
AGENT_SKIP_NOT_READY_MAX_PCT, missing RBAC, broken rollout, stale status)keeps the check strict.
Prerequisites
kind create cluster --name skip-notready).operator-checkimage built from this PR, loaded in kind. SetCHECK_IMAGEto its name (defaultoperator-check:skip-notready).datadog(the Operator itself is unchanged by this PR; any recent version works):Why the threshold settings below: the check runs as a Job like the Helm hook, with
AGENT_COMPLETION_MIN=0(the default10would pass on a 5-node cluster without skipping anything) andCHECK_TIMEOUT_MINUTES=2so failing cases end quickly. With 5 Agent nodes, the default 10% cap allowsint(5 × 0.10) = 0skipped nodes, so the passing cases raiseAGENT_SKIP_NOT_READY_MAX_PCT.Files
dda.yaml:check-rbac.yaml:run-check.sh(runs one check as a Job, prints PASSED/FAILED and its logs):Steps
##### 1. Deploy the Agent
Baseline:
./run-check.sh baseline true 25→PASSED, nothing skipped.The first log line must list the settings:
skip not-Ready nodes: true, max skipped pct: 25.##### 2. One dead node during a rollout
Expected state: 4 new pods; the old pod on
worker3staysTerminatingforever (its kubelet is gone).| # | Command | Expected result | Expected log line |
|---|---|---|---|
| 1 |
./run-check.sh 1-skip-off false 25|FAILED(timeout) |[Agent] nb pods: 5, nb updated pods: 4on every poll || 2 |
./run-check.sh 2-default-10pct true 10|FAILED|[Agent] not skipping not-Ready nodes: 4/5 nodes up to date, not enough even with 0 nodes skipped(10% of 5 nodes is 0, so no API call) || 3 |
./run-check.sh 3-pct-25 true 25|PASSEDon the first poll |[Agent] skipping 1 not-Ready nodes with an out-of-date Agent pod, counting 4 nodes instead of 5, thenreached threshold): 4, nb updated pods: 4|| 5 | Missing node RBAC (below) |
FAILED|unable to count not-Ready nodes, not skipping any: unable to list nodes: ... cannot list resource "nodes"|Case 5:
##### 3. Two dead nodes: the skip cap
| # | Command | Expected result | Expected log line |
|---|---|---|---|
| 6 |
./run-check.sh 6-two-dead-cap-25 true 25 1|FAILED|[Agent] not skipping not-Ready nodes: 2 not-Ready nodes with an out-of-date Agent pod, above the 1 cap|| 7 |
./run-check.sh 7-two-dead-pct-40 true 40|PASSED|skipping 2 not-Ready nodes ... counting 3 nodes instead of 5, thenreached threshold): 3, nb updated pods: 3|(Case 6 passes
AGENT_COMPLETION_MIN=1so the check gets past its pre-check and actually counts the 2 nodes.)##### 4. A broken rollout still blocks the check
| # | Command | Expected result | Expected log line |
|---|---|---|---|
| 8 |
./run-check.sh 8-broken-config-pct-100 true 100|FAILED| Anot skipping not-Ready nodes: ...line, and stillnb updated pods: 1. The live DaemonSet shows 1/5 updated, so even skipping every not-Ready node cannot pass. Ready nodes with old pods are never skipped, even with a 100% cap. |##### 5. A stale DatadogAgent status does not pass a new rollout
Start from the state of step 2 (one dead node, rollout finished on the healthy nodes). Stop the Operator so that the DatadogAgent status stops updating, then start a rollout on the DaemonSet directly:
| # | Command | Expected result | Expected log line |
|---|---|---|---|
| 9 |
./run-check.sh 9-stale-status true 25, right after the patch |FAILEDon the first polls, thenPASSEDonly once the live DaemonSet shows the healthy nodes updated |not skipping not-Ready nodes: 2/5 nodes up to date, ...while the live DaemonSet rolls out, thenskipping 1 not-Ready nodes ..., counting 4 nodes instead of 5|Restore the Operator afterwards:
kubectl -n datadog scale deploy datadog-operator --replicas=1.##### Cleanup
Notes for the reviewer
node.kubernetes.io/unreachable:NoScheduletaint (the DDA usesoperator: Exists). Without it, the DaemonSet status already drops the dead node and there is nothing to skip.Error: unable to list DatadogAgentInternals: context deadline exceeded. That is how the existing check reports its timeout, not a new error.Terminatingpod uses onemaxUnavailableslot. If a cluster has more dead nodes thanmaxUnavailable, the DaemonSet rollout itself stalls, and this setting cannot help.Results on kind (2026-10-28,
e84e05c7)| # | Scenario | Settings | Result |
|---|---|---|---|
| 1 | 1 dead node, 4/5 updated | skip off | FAILED (timeout) |
| 2 | same | skip on, 10% (0 nodes on 5) | FAILED,
not skipping ... not enough even with 0 nodes skipped|| 3 | same | skip on, 25% | PASSED,
skipping 1 not-Ready nodes ..., counting 4 nodes instead of 5|| 5 | same | 25%, no
list nodesRBAC | FAILED,cannot list resource "nodes"logged || 9 | Operator stopped, DaemonSet patched: live 1/5 updated, DDA status still 5/4 | 25% | Waited while the live DaemonSet rolled out (
2/5,3/5logged), then PASSED at 4/5 skippingworker3|Cases 6–8 ran on #3650 (same counting rules) and were not rerun on this branch. Since these runs, the branch was rebased on
main, the skip log no longer names the nodes, and the taint and affinity checks were replaced by subtractingnumberMisscheduledfrom each DaemonSet's discount. On the same kind cluster, removing the Agent tolerations made the deadworker3leavecurrentNumberScheduled(5 → 3, with the control-plane) and show up asnumberMisscheduled=1, which is what the check subtracts.</details>
Checklist
qa/skip-qalabel🤖 Generated with Claude Code