← Back to Pull requests

OCPBUGS-114014: automate Agent CAPI resource pause/unpause during backup and restore #305

Closed
unknown closed this pull request without merging on Aug 26, 2026 15:38 UTC
View on GitHub
unknown unknown commented on Aug 26, 2026 10:23 UTC
Author

Summary

Automate the pause/unpause of AgentMachine and AgentCluster CAPI resources during backup and restore operations, removing the need for manual user intervention when node readoption is intended.

Problem

During backup, the CAPI Agent provider can reconcile AgentMachine and AgentCluster resources, causing the ClusterDeploymentsReconciler to unbindAgents — which removes agents from the hosted cluster as nodes and destroys workloads. This was previously a manual step users had to perform before and after backup/restore.

Solution

Handle the pause/unpause lifecycle automatically in the plugin:

  • Backup (Execute in backup.go): When processing AgentMachine or AgentCluster items on Agent platform with migration mode enabled (migration: "true" in plugin ConfigMap), add the cluster.x-k8s.io/paused: "true" annotation to the item before passing it to Velero. This is gated by the Migration config flag because the pause is only needed when node readoption is intended — if nodes are being reprovisioned, there is no risk of agent unbinding.
  • Restore (Execute in restore.go): When processing AgentMachine or AgentCluster items, remove the cluster.x-k8s.io/paused annotation unconditionally so the CAPI provider resumes reconciliation immediately after restore. No config check is needed here — if the annotation exists, it should always be removed.
  • This follows the same pattern the plugin already uses for other Agent-specific modifications (e.g., PreserveOnDelete on ClusterDeployment via agent.MigrationTasks()).

    Changes

    | File | Change |
    |------|--------|
    | pkg/common/types.go | Added AgentMachineKind, AgentClusterKind, CAPIPausedAnnotation constants |
    | pkg/core/backup.go | New case: add CAPI paused annotation to AgentMachine/AgentCluster (Agent platform + Migration mode only) |
    | pkg/core/restore.go | New case: remove CAPI paused annotation from AgentMachine/AgentCluster (unconditional) |
    | pkg/core/backup_test.go | 4 tests: pause with migration, pause AgentCluster with migration, no-op on non-Agent, no-op without migration |
    | pkg/core/restore_test.go | 3 tests: remove pause from AgentMachine, AgentCluster, pass-through without annotation |

    Testing

    All existing and new tests pass (make test).

    Jira

    OCPBUGS-114014

    References

  • Upstream DR docs: Agent Platform Guide

  • E2E test doing manual pause: backup_restore_test.go:183-190

  • Slack discussion with Crystal (Assisted Service team) confirming the need for pause to prevent agent unbinding
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added backup and restore support for AgentMachine and AgentCluster resources.
    Backups pause these resources during Agent-platform migrations, while restores remove the pause marker.
    Resources without the marker remain unchanged.
    Bug Fixes
    Improved metadata error messages to identify the affected resource type.
    Prevented pause behavior when migration is disabled or running on other platforms.
    Tests
    * Added coverage for Agent resource backup and restoration behavior across supported platforms.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 440 lines (+330 / -110) across 5 files Reviewer: mgencur Review duration: 315m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 440 lines diff across 5 files
    0.45
    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.364
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #305"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    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: 45.3% (MEDIUM) · Higher = larger blast radius
    45.3%
    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: 17.9% · Safe to merge
    17.9%