← Back to Pull requests

fix: capture populate pod logs during migration to handle quick pod cleanup #553

Closed
unknown closed this pull request without merging on Jul 06, 2026 08:21 UTC
View on GitHub
unknown unknown commented on Jun 14, 2026 12:13 UTC
Author

Problem

MTV build 125ee50a81aecafbfd8a805976de2642d6b93ae8 deletes populate pods immediately (within milliseconds) when migration succeeds, causing test_check_xcopy_used to fail with "No populate pods found" error.

MTV build 179b34f5ea6d7e9d4cebe4492df081e84ea8c837 keeps populate pods around longer, allowing tests to pass.

Evidence


From Jenkins build #36 using MTV build 125ee50:
  • 11:30:46.562 - Migration succeeds

  • 11:30:48.621 - test_check_xcopy_used starts (2 seconds later)

  • 11:30:48.876 - Test FAILS - populate pods already deleted
  • Root Cause in MTV


    Commit: a46e47690 (MTV-5655) - June 2, 2026

    This commit changed when populate pods get cleaned up:

    Before MTV-5655:

  • Populate pods lived longer after migration completed

  • Cleanup happened during archive phase
  • After MTV-5655:

  • Cleanup happens immediately after ConditionSucceeded is set

  • Added call to cleanup(vm, dontFailOnError, true) right after migration success

  • Populator pods deleted within milliseconds, not seconds
  • Timeline:
    1. Migration completes → ConditionSucceeded set
    2. MTV immediately calls cleanup() (commit a46e47690)
    3. cleanup() calls DeletePopulatorPods()
    4. Pods deleted in milliseconds
    5. Test tries to check pods → Already gone ❌

    Solution

    Capture populate pod logs DURING migration execution, before MTV's cleanup can delete them, using a callback pattern that keeps copy-offload logic separate from general migration code.

    Changes Made

    1. Added callback pattern to wait_for_migration_complate() in utilities/mtv_migration.py
    - New optional parameter: on_status_poll - callback invoked on each poll with current migration status
    - Keeps general migration code clean - no copy-offload-specific logic
    - Allows any feature to hook into the migration status polling loop

    2. Created execute_copyoffload_migration() in utilities/copyoffload_migration.py
    - Wrapper function for copy-offload migrations
    - Creates Migration CR and waits for copy-offload plan secret readiness
    - Uses create_log_capture_callback() to build a status poll callback
    - Passes callback to wait_for_migration_complate() for automatic log capture
    - All copy-offload tests updated to use this wrapper instead of general execute_migration()

    3. Created create_log_capture_callback() in utilities/copyoffload_migration.py
    - Factory function that creates a callback for wait_for_migration_complate()
    - Callback captures populate pod logs when migration status is EXECUTING
    - Only captures once per migration to avoid repeated API calls
    - Stores logs in fixture_store["populate_pod_logs"][migration_uid]

    4. Updated capture_populate_pod_logs() in utilities/copyoffload_migration.py
    - Made idempotent - merges new captures with existing cached logs
    - Captures from Running, Succeeded, or Failed pods (wherever logs are available)
    - Better error handling per-pod with detailed logging

    5. Updated get_populate_pod_logs() in utilities/copyoffload_migration.py
    - Merges cached logs with live pods (fills cache gaps)
    - Returns complete log set from both sources
    - Handles case where some pods are cached but others are still live

    Why This Works

  • Capture timing: Runs during migration (status == EXECUTING) before MTV sets ConditionSucceeded

  • Before cleanup: Pods still exist when we capture their logs

  • Idempotent: Safe to call multiple times, only captures once per migration

  • Backwards compatible: Falls back to querying live pods if cached logs not available

  • Clean architecture: Copy-offload logic stays in copyoffload_migration.py, general code stays general
  • Testing

    ✅ All pre-commit checks pass (mypy, flake8, ruff, formatting)
    ✅ Captures logs before MTV's immediate cleanup deletes pods
    ✅ Backwards compatible with both MTV build behaviors
    ✅ Jenkins job #56: 20 tests passed (all migrations that executed used our code successfully)

    Related Issues

    This fix resolves the test_check_xcopy_used failures observed in:

  • Jenkins build #33 (6 failures)

  • Jenkins build #36 (7 failures)

  • Jenkins build #37 (7 failures) - First attempt at fix, didn't capture early enough
  • Builds using MTV 179b34f (like #34) will continue to work via the fallback to live pod queries.

    MTV Upstream Reference

    The populate pod cleanup behavior change was introduced in:

  • Commit: a46e47690e32f7c1a7b460a7aa3ddbdbe15dd1dd

  • PR: #6628

  • Issue: MTV-5655

  • Title: "Fix populator pod cleanup and prevent PVC cascade deletion"

  • Date: June 2, 2026
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added a copy-offload execution helper that automatically captures populate-pod logs for XCOPY verification.
    Introduced dual-plan and enhanced concurrent plan completion monitoring with per-plan status callbacks.
    Bug Fixes
    Improved XCOPY used verification by using cached populate-pod logs (with datastore context) to reduce dependency on live pods.
    Hardened polling/completion behavior and tightened migration UID resolution; narrowed SSH retryable error handling.
    Documentation
    Updated copy-offload XCOPY test orchestration guidance and execution modes.
    Tests
    Updated copy-offload and MTV concurrency/multi-plan tests to use shared fixture storage and plan-aware callbacks/completion helpers.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: tshefi Review duration: 31448m
    All Vouch review confidence checks passed
    Residual risk 0.32 = Change Risk (0.75) × (1 − Review Confidence (0.58)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 650 lines diff across 8 files
    0.75
    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%
    57%
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #553"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 58.0% 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: 75.2% (HIGH) · Higher = larger blast radius
    75.2%
    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: 58.0% · Lower = rushed or shallow review
    58.0%
    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: 31.6% · Safe to merge
    31.6%