[deckhouse-cli] Updating the debug archive and adding an archive for virtualization - #472
Conversation
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>
Signed-off-by: Valery Losev <valery.losev@flant.com>
There was a problem hiding this comment.
🟡 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
runCommandshelper. - 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 virtualizationto collect per-pod logs fromd8-virtualizationwith 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--excludevalues likecsi-controller-logsand makes--list-excludeoutput 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.
Glitchy-Sheep
left a comment
There was a problem hiding this comment.
Two things to fix before merging, both in the base archive:
--excludeand--list-excludebreak for per-module files after the rename. See the inline comment.- 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.
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>
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>
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>
Signed-off-by: Valery Losev <valery.losev@flant.com>
Signed-off-by: Valery Losev <valery.losev@flant.com>
…date-collection-logs-for-archive
Changes to the archive generated by the
d8 system collect-debug-infocommand:CRDresources from the cluster has been added.machineresources forMCMandCAPIhas been improved.exec→tarloop was moved from theTarball()function to the reusablerunCommandsfunction so it can be used when creating a new archive for virtualization.--list-excludeand--excludeflags have been moved to separate files to improve code readability; tests have also been added for them.README.mdfile ininternal/systemhas been updated.The
ExpandPerModule boolfield has been removed from theCommandstructure; the decision to execute a command for all modules specified inRequiredModuleis now based on the presence of the{module-name}placeholder in theFileorArgsfields. This ensures a single source of truth for this mechanism—the template itself.A test has also been added to verify that
{module-name}is not used without specifyingRequiredModule.Additionally, a separate command has been added to collect logs from all pods in the
d8-virtualizationnamespace:d8 system collect-debug-info virtualization. This was done because the 3,000-line limit is often insufficient for diagnosing virtualization issues, and the logs fromvirt-handlerpods (deployed via a DaemonSet on every node) are also crucial—yet there can be many such pods (depending on the number of nodes).Including all these logs in the main archive would significantly increase its size, whereas a debug archive needs to remain a tool for rapid diagnostics, allowing clients to quickly gather and submit it. Thus, if virtualization issues arise and the standard archive's logs prove insufficient, a specialized virtualization-focused archive can be requested.
The
--command-timeoutand--request-intervalflags were carried over to this new archive, and a new--skip-ds-logsflag was added; this allows for disabling log collection from DaemonSet (DS) pods in clusters with a large number of nodes.Changes to
internal/utilk8s/operatepod.go:To collect
virtualizationlogs without using the Deckhouse pod, theExecCommandInPodfunction and a privatesyncBuffertype were added to theutilk8spackage. This addition follows a comment regarding an issue with buffer reuse, which could potentially corrupt the logs.#472 (comment)
Changes to
internal/utilk8s/clientset.go:The
SetupK8sClientSetmechanism and the identical error message "Failed to setup Kubernetes client: %w" were previously duplicated across the standard and virtualization archive collection processes. This logic has now been moved to theutilk8spackage, where similar mechanisms are utilized.