OCPBUGS-114014: automate Agent CAPI resource pause/unpause during backup and restore #305
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
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.364
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #305"
general
weight: 0.35
mgencur
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
ClusterDeploymentsReconcilertounbindAgents— 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:
Executeinbackup.go): When processing AgentMachine or AgentCluster items on Agent platform with migration mode enabled (migration: "true"in plugin ConfigMap), add thecluster.x-k8s.io/paused: "true"annotation to the item before passing it to Velero. This is gated by theMigrationconfig flag because the pause is only needed when node readoption is intended — if nodes are being reprovisioned, there is no risk of agent unbinding.Executeinrestore.go): When processing AgentMachine or AgentCluster items, remove thecluster.x-k8s.io/pausedannotation 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.,
PreserveOnDeleteon ClusterDeployment viaagent.MigrationTasks()).Changes
| File | Change |
|------|--------|
|
pkg/common/types.go| AddedAgentMachineKind,AgentClusterKind,CAPIPausedAnnotationconstants ||
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
<!-- 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 -->