Skip to content

feat(scripts): add support-bundle log collector and HTML report (partial #429) - #1946

Open
valentin-pf9 wants to merge 2 commits into
platform9:mainfrom
valentin-pf9:feature/support-bundle-scripts
Open

feat(scripts): add support-bundle log collector and HTML report (partial #429)#1946
valentin-pf9 wants to merge 2 commits into
platform9:mainfrom
valentin-pf9:feature/support-bundle-scripts

Conversation

@valentin-pf9

@valentin-pf9 valentin-pf9 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds scripts/support-bundle/ with two tools for post-mortem migration analysis:

  • collect-logs.sh — gathers controller logs, every v2v-helper-* pod's logs in migration-system, the Migration CRD, related CRDs (MigrationPlan, MigrationTemplate, NetworkMapping, StorageMapping, VjailbreakNode, VMwareMachine/Cluster/Host, RDMDisk), credentials (redacted), Kubernetes events from both namespaces, and the vjailbreak-settings ConfigMap into a single .tar.gz.

  • parse-logs.py — takes a bundle and produces a self-contained report.html with: migration health card (phase, parsed duration, suggested root cause + remediation), per-disk copy table, event timeline, CBT iteration table, errors categorized by subsystem (DNS, vCenter, NBD/VDDK, virt-v2v, OpenStack, Kubernetes, Auth, Network), pod restart count / exit reason, network & storage mappings as tables, sortable Kubernetes events, and a vanilla-JS search box.

  • README.md — install, usage, limitations.

  • test_parse_logs.py — 20 unittest cases covering the parser (run via python3 -m unittest test_parse_logs.py -v).

Scope

Partial address of #429 — specifically the "Expose through logs" approach. Does not replace a live in-UI dashboard; it's a support-engineer post-mortem tool, not an end-user one. Happy to follow up with a Prometheus-metrics output mode (--format prometheus) if that's wanted (per @roopakparikh's comment on #429).

Credentials safety

Before anything is written to the tarball, credentials CRDs (vmwarecreds, openstackcreds, arraycreds, esxisshcreds) are piped through jq. Any field whose key matches password|secret|token|key|credential (case-insensitive) is replaced with ***REDACTED***. Tarballs are safe to share / upload.

Verified against the real codebase

  • API group: vjailbreak.k8s.pf9.io v1alpha1 — k8s/migration/api/v1alpha1/groupversion_info.go:29
  • Namespaces: migration-system and vjailbreak
  • v2v-helper pod naming: v2v-helper-<vmk8sname>-<sha>pkg/utils/migrationplanutils.go:GetJobNameForVMName
  • Migration phases: all 19 phases from migration_types.go:28 have explicit CSS styling
  • Event log patterns (disk copy, CBT sync, virt-v2v) pulled from v2v-helper/migrate/migrate.go

Test plan

  • python3 -m unittest scripts/support-bundle/test_parse_logs.py -v — 20 tests, all pass (0.005s)
  • End-to-end smoke test: collect-logs.sh --migration <name> --dest local against a kind cluster with planted Migration CRDs and fake v2v-helper pods produces a valid tarball; parse-logs.py on that tarball produces a populated report.html with non-empty health card, disk table, CBT iterations, event timeline, categorized errors, and root-cause suggestion.
  • (Maintainers) test against a real vjailbreak appliance with an actual migration.

What this does not do (yet, happy to follow up)


Open in Devin Review

Adds scripts/support-bundle/ with two tools for post-mortem migration
analysis:

- collect-logs.sh: gathers controller logs, v2v-helper pod logs,
  migration CRDs, related CRDs (MigrationPlan, mappings, etc.), Kubernetes
  events, and the vjailbreak-settings ConfigMap into a single .tar.gz.
  Credentials (vmwarecreds, openstackcreds, arraycreds, esxisshcreds) are
  piped through jq before tarring; any field whose key matches
  password|secret|token|key|credential is replaced with ***REDACTED***.
  Supports four destinations: local, gdrive (rclone), sftp (scp), s3 (rclone).

- parse-logs.py: takes a bundle and produces a self-contained report.html.
  Extracts migration health (phase, parsed duration, suggested root cause +
  remediation), per-disk copy timeline (size, throughput, CBT iteration
  count), categorised errors (DNS, vCenter, NBD/VDDK, virt-v2v, OpenStack,
  Kubernetes, Auth, Network), pod restart count, network/storage mapping
  tables, sortable Kubernetes events table, and a vanilla-JS search box.

- README.md: install/usage/limitations.

deploy/installer.yaml and deploy/00crds.yaml were regenerated by the
pre-commit make build-installer hook (current branch name in image tags).

Partially addresses platform9#429 (the 'Expose through logs' approach). Does not
replace a live in-UI dashboard; intended as a support-engineer tool.
Verified against the real CRD types in k8s/migration/api/v1alpha1/.
20 unittest cases covering:
- parse_disk_copies: basic two-disk flow, regression for the 0-based-vs-
  1-based index bug, CBT attribution to the correct disk, empty input.
- parse_cbt_iterations: iteration extraction with disk/duration/progress.
- categorize_errors: DNS, vCenter, NBD/VDDK buckets; non-error lines
  excluded; unknown patterns fall through to Other.
- suggest_root_cause: DNS and VDDK heuristics fire; clean logs yield None.
- parse_pod_describe: extracts name, restart count, image, exit reason.
- parse_events: disk.copy.start, migration.complete, Go log timestamp.
- extract_mapping_entries: network mapping rows; empty YAML safe.

Run from scripts/support-bundle/:
  python3 -m unittest test_parse_logs.py -v

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant