Skip to content

[deckhouse-cli] Updating the debug archive and adding an archive for virtualization - #472

Open
VaLosev wants to merge 9 commits into
mainfrom
chore/update-collection-logs-for-archive
Open

[deckhouse-cli] Updating the debug archive and adding an archive for virtualization#472
VaLosev wants to merge 9 commits into
mainfrom
chore/update-collection-logs-for-archive

Conversation

@VaLosev

@VaLosev VaLosev commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

In the current archive, which is collected with the command: d8 system collect-debug-info

  • Renamed data collection files to group data from different components:
  • Added a 3000-line limit for collecting logs from virtualization module controllers
  • Added CRD collection from the cluster
  • Fixed a bug related to collecting machine resources for CAPI. MCM machine has been moved to a separate file - instance-manager-mcm-cloud-machines.json
  • The exec→tar cycle has been moved from Tarball() to a reusable runCommands so that it can be used in the new virtualization archive.

The ExpandPerModule bool field has been removed from Command; the decision to execute the command for all modules found in RequiredModule is now based on the presence of {module-name} in the File or Args fields. This ensures there is a single source of truth for this mechanism: the template itself.
A test has also been added to ensure that {module-name} is not used without RequiredModule.


Also added a separate command for collecting logs from all pods from ns - d8-virtualization: d8 system collect-debug-info virtualization
This was done because 3000-line logs are often insufficient for virtualization diagnostics, and logs from virt-handler pods, which are launched via DS on each node, are also very important - there can be many of them. (by number of nodes)

Collecting all these logs into the main archive could significantly increase its size, and the debug archive should remain a quick diagnostic tool so clients can quickly collect and send it.

So, in the event of virtualization issues, if the standard archive's logs are insufficient, a special virtualization archive can be requested.

The --command-timeout and --request-interval flags have been copied to this new archive, and a new --skip-ds-logs flag has been added to disable log collection from DS modules in the case of a large number of nodes.

d8 system collect-debug-info virtualization --help
Collect a separate debug archive with detailed data from the d8-virtualization namespace.

Usage:
  d8 system collect-debug-info virtualization [flags] > deckhouse-debug-virtualization-$(date +"%Y_%m_%d").tar.gz

Examples:
  # Collect the virtualization debug archive:
  d8 system collect-debug-info virtualization > deckhouse-debug-virtualization-$(date +"%Y_%m_%d").tar.gz

  # The --skip-ds-logs flag can be used to skip logs from DaemonSet-managed pods
  # (virt-handler, virtualization-dra, vm-route-forge, ...) to reduce archive size:
  d8 system collect-debug-info virtualization --skip-ds-logs > deckhouse-debug-virtualization-$(date +"%Y_%m_%d").tar.gz

Flags:
      --command-timeout duration    Timeout for each individual debug command execution (default 2m0s)
  -h, --help                        help for virtualization
      --request-interval duration   Minimum interval between debug command executions to avoid overloading the cluster (e.g. 200ms, 500ms, 1s). Zero disables rate limiting (default 0s)
      --skip-ds-logs                Skip collecting logs from pods managed by a DaemonSet (virt-handler, virtualization-dra, vm-route-forge, ...) to reduce archive size on clusters with many nodes

Global Flags:
      --context string      The name of the kubeconfig context to use
  -k, --kubeconfig string   Path to kubeconfig file. (default is $KUBECONFIG when it is set, otherwise the default kubeconfig path for the current OS user) (default "/Users/valery.losev/.kube/config")

Signed-off-by: Valery Losev <valery.losev@flant.com>
Signed-off-by: Valery Losev <valery.losev@flant.com>
@VaLosev VaLosev self-assigned this Sep 1, 2026
@VaLosev
VaLosev requested a review from ldmonster as a code owner September 1, 2026 14:21
Signed-off-by: Valery Losev <valery.losev@flant.com>
Signed-off-by: Valery Losev <valery.losev@flant.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

There are user-facing behavioral issues (notably --exclude no longer matching module-expanded filenames as documented) and reliability issues from ignoring tar/gzip Close() errors that can produce silently corrupted archives.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR enhances d8 system collect-debug-info by reorganizing debug archive contents (renamed output files, additional collected resources) and extracting a reusable command-execution pipeline, while also introducing a dedicated virtualization subcommand to collect a separate, more detailed archive for the d8-virtualization namespace.

Changes:

  • Refactored the tarball creation flow by extracting the exec→tar loop into a reusable runCommands helper.
  • Renamed/added collected artifacts in the main debug archive (including CRD collection and additional virtualization module controller logs with tail limits).
  • Added d8 system collect-debug-info virtualization to collect per-pod logs from d8-virtualization with an option to skip DaemonSet-owned pod logs.
File summaries
File Description
internal/system/cmd/collect-debug-info/virtualizationtar/virtualizationTar.go Adds the new virtualization cobra subcommand and CLI flags.
internal/system/cmd/collect-debug-info/debugtar/virtualizationTarball.go Implements the virtualization-focused tarball (pod discovery + per-pod logs).
internal/system/cmd/collect-debug-info/debugtar/debugTar.go Renames/extends the main debug command list and extracts runCommands.
internal/system/cmd/collect-debug-info/collect-debug-info.go Wires the new virtualization subcommand into collect-debug-info.
Review details

Suppressed comments (1)

internal/system/cmd/collect-debug-info/debugtar/debugTar.go:177

  • Same issue as the CCM logs filename: {module-name} prefix breaks prefix-based --exclude values like csi-controller-logs and makes --list-exclude output less useful. Keeping the placeholder at the end preserves existing exclusion behavior.
		File:            "{module-name}-csi-controller-logs.txt",
  • Files reviewed: 4/4 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/system/cmd/collect-debug-info/debugtar/debugTar.go Outdated
Comment thread internal/system/cmd/collect-debug-info/debugtar/debugTar.go
Comment thread internal/system/cmd/collect-debug-info/collect-debug-info.go
Comment thread internal/system/cmd/collect-debug-info/debugtar/virtualizationTarball.go Outdated
ldmonster
ldmonster previously approved these changes Sep 3, 2026

@Glitchy-Sheep Glitchy-Sheep left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two things to fix before merging, both in the base archive:

  1. --exclude and --list-exclude break for per-module files after the rename. See the inline comment.
  2. MCM machines are dropped from the archive instead of being collected alongside CAPI machines. See the inline comment.

One thing to decide: renaming almost every file in the archive is a breaking change. It affects existing --exclude values, support scripts and the docs on the site. The card and the thread did not ask for it. If we keep it, please state it in the PR description and update the --exclude example in the help once the exclude logic is fixed.

Optional: --all-containers=true in the log commands would also capture sidecars, for example the second container of dvcr. kubectl defaults to the first container, so this is not blocking.

Comment thread internal/system/cmd/collect-debug-info/debugtar/debugTar.go Outdated
Comment thread internal/system/cmd/collect-debug-info/debugtar/debugTar.go
Signed-off-by: Valery Losev <valery.losev@flant.com>
@VaLosev
VaLosev marked this pull request as draft September 7, 2026 17:04
Signed-off-by: Valery Losev <valery.losev@flant.com>
Signed-off-by: Valery Losev <valery.losev@flant.com>
Signed-off-by: Valery Losev <valery.losev@flant.com>
@VaLosev
VaLosev marked this pull request as ready for review September 8, 2026 18:22
Signed-off-by: Valery Losev <valery.losev@flant.com>
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.

4 participants