← Back to Pull requests

[profile] keep legacy profile label until DaemonSets migrate #3840

Closed
unknown closed this pull request without merging on Nov 24, 2026 21:54 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 12:55 UTC
Author

What does this PR do?

Stacked on #3839. Makes the upgrade to namespace-scoped profile labels safe:

  • Keep the legacy agent.datadoghq.com/datadogagentprofile node label until no operator-managed DaemonSet selects with it. agentprofile.LegacyProfileLabelInUse checks DaemonSets with app.kubernetes.io/managed-by=datadog-operator for the legacy key in required or preferred node affinity. labelNodesWithProfiles only removes the legacy label once nothing uses it.

  • Create strategy: a node whose legacy label already names the profile counts as already labeled, so existing profile nodes aren't throttled as if they were new.

  • Cross-namespace DAP status: a watched DAP outside the DDA's namespace is marked Applied=False with reason NoDatadogAgentInNamespace, and its createStrategy status is cleared. Before this, it kept a stale Applied=True. Documented in docs/datadog_agent_profiles.md.
  • Only a single DDA per cluster is supported (with any number of profile DDAIs), so multi-DDA scenarios aren't handled.

    Motivation

    Reproduced on a 6-node kind cluster by upgrading from the base commit (379edc6e2) to #3839. The setup was a DAP gpu on 4 nodes, the create strategy enabled, and DaemonSet maxUnavailable: 1:

  • With #3839: all 4 profile pods were deleted in the same second. #3839 removes the legacy label before the DaemonSets get the new affinity, so the DaemonSet controller evicts the pods directly instead of rolling them. Default pods were also created on the profile nodes and deleted about a second later. The profile agents were down on every profile node for about 30s.

  • With #3839: a team-a DAP that had been applied cross-namespace stayed Applied=True and createStrategy: Completed after it stopped applying.
  • Additional Notes

  • While the legacy label is kept, its value isn't updated. It's removed on the next reconcile once the DaemonSets are re-rendered (the 15s requeue), and the cluster run took about 1s. Node removal only waits for the DaemonSet spec, not the rollout, which is enough for the DaemonSet controller's node matching.

  • DAPs outside the watch namespaces aren't visible to the operator, so their status can't be updated. The docs say so.

  • If the DDA's spec.override.nodeAgent.affinity references the legacy key, that affinity is merged into every DaemonSet, and the legacy label is kept for as long as it stays there.
  • Minimum Agent Versions

    N/A

    Describe your test plan

  • go test ./internal/controller/datadogagent/ ./internal/controller/datadogagentinternal/ ./pkg/agentprofile/, make integration-tests and make lint all pass.

  • New unit tests cover: DaemonSet detection (required/preferred terms, default DoesNotExist, unmanaged DaemonSets); labelNodesWithProfiles keeping or removing the legacy label; create strategy counting the legacy label; markCrossNamespaceProfiles.

  • Repeated the kind upgrade (base → this branch, operator watching all namespaces):

  • - Both labels were present for about 1s. Once the DaemonSets were re-rendered, the legacy label was removed.
    - The gpu pods rolled one at a time, about 30s apart: 13:51:42, 13:52:12, 13:52:42, 13:53:13.
    - No default pods ran on profile nodes.
    - team-a/edge → Applied=False, reason NoDatadogAgentInNamespace, createStrategy: null.
    - No errors in the operator logs.

    The kind run used the first commit, which also included the multi-DDA handling removed in the second commit. The single-DDA upgrade path it exercised is unchanged.

    Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies

  • PR has a milestone or the qa/skip-qa label

  • All commits are signed (see: [signing commits][1])
  • [1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

    🤖 Generated with Claude Code

    Diff: 494 lines (+370 / -124) across 6 files Reviewer: khewonc Review duration: 539m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.71) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.71 · 494 lines diff across 6 files
    0.71
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.371
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.071
    Real PR Conversation Timeline
    1 comments
    "Review active on #3840"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 70.6% (HIGH) · Higher = larger blast radius
    70.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.9% · Safe to merge
    27.9%