Conversation
|
Skipping CI for Draft Pull Request. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Excluded labels (none allowed) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis PR adds context support to snapshot operations, upgrades the ghw dependency to v0.23.0, refactors GHWHandler to support compressed Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jmencak The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
pkg/performanceprofile/profilecreator/cmd/info.go (1)
40-52:⚠️ Potential issue | 🟠 Major
makeClusterDataerrors can still leak unpacked snapshots.This defer only runs after
makeClusterDatasucceeds. In info mode, a later pool failure can discard handlers already stored for earlier pools without callingCleanup(), so the temp dirs introduced by archive unpacking are leaked. Please add cleanup insidemakeClusterDatabefore returning any error after handlers have been appended.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/performanceprofile/profilecreator/cmd/info.go` around lines 40 - 52, The makeClusterData function can append handlers (temp-dir resources) then return an error without cleaning them up; modify makeClusterData so that whenever it returns a non-nil error after any handlers have been appended to the clusterData slice/map it iterates those already-created handlers and calls their Cleanup() (handling/logging any cleanup errors) before returning the error, ensuring no unpacked snapshots remain; reference the makeClusterData function and the handler.Cleanup() method used in the deferred cleanup of clusterData in info.go.pkg/performanceprofile/profilecreator/cmd/root.go (1)
158-168:⚠️ Potential issue | 🟠 MajorCleanup still misses partial
makeNodesHandlersfailures.This defer is registered only after
makeNodesHandlerssucceeds. If one node fails after earlier archive-backed handlers were already created, those handlers' unpacked temp dirs are leaked because the helper drops the partial slice on error.💡 Suggested fix
func makeNodesHandlers(mustGatherDirPath, poolName string, nodes []*corev1.Node) ([]*profilecreator.GHWHandler, error) { - handlers := make([]*profilecreator.GHWHandler, len(nodes)) + handlers := make([]*profilecreator.GHWHandler, 0, len(nodes)) sb := strings.Builder{} - for i, node := range nodes { + for _, node := range nodes { handle, err := profilecreator.NewGHWHandler(mustGatherDirPath, node) if err != nil { + for _, h := range handlers { + _ = h.Cleanup() + } return nil, fmt.Errorf("failed to load node's GHW snapshot: %w", err) } - handlers[i] = handle + handlers = append(handlers, handle) sb.WriteString(node.Name + " ") }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/performanceprofile/profilecreator/cmd/root.go` around lines 158 - 168, The current code registers the cleanup defer only after makeNodesHandlers returns nil error, which leaks temp dirs when makeNodesHandlers fails after creating some handlers; change the call site so you capture the returned nodesHandlers slice and immediately defer iterating and calling handler.Cleanup() on any non-nil entries before inspecting err (i.e., place the defer right after assigning nodesHandlers, not inside the success branch), and ensure makeNodesHandlers still returns any partially-created handlers on error so the deferred cleanup can run (refer to makeNodesHandlers, nodesHandlers, and handler.Cleanup).
🧹 Nitpick comments (1)
pkg/performanceprofile/profilecreator/profilecreator_test.go (1)
233-235: Add one archive-backedNewGHWHandlertest.These cleanup additions still only exercise directory-backed must-gather input. The new
.tgz/.tar.gzbranch and its failure cleanup inghwhandler.goremain uncovered, so this migration can regress without a test catching it.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/performanceprofile/profilecreator/profilecreator_test.go` around lines 233 - 235, Add a test that exercises the archive-backed path of NewGHWHandler by creating a temporary .tgz (or .tar.gz) must-gather archive containing the same test fixture files used by the directory-backed tests, call NewGHWHandler with the archive path and the same node input, assert no error, and ensure DeferCleanup(handle.Cleanup) is used so the failure/cleanup branch in ghwhandler.go is executed; target the NewGHWHandler call site in profilecreator_test.go and verify the handler can open and later Cleanup an archive-backed must-gather to cover the .tgz/.tar.gz branch.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/performanceprofile/profilecreator/ghwhandler.go`:
- Around line 52-56: When snapshot.Unpack(...) returns an error the temp
directory at tmpDir is left behind; update the error path after calling
snapshot.Unpack in ghwhandler.go to remove the temp dir (e.g., call
os.RemoveAll(tmpDir)) before returning the fmt.Errorf; ensure you only attempt
cleanup when tmpDir is non-empty and preserve the original error returned by
snapshot.Unpack so the function still returns the same error payload.
---
Outside diff comments:
In `@pkg/performanceprofile/profilecreator/cmd/info.go`:
- Around line 40-52: The makeClusterData function can append handlers (temp-dir
resources) then return an error without cleaning them up; modify makeClusterData
so that whenever it returns a non-nil error after any handlers have been
appended to the clusterData slice/map it iterates those already-created handlers
and calls their Cleanup() (handling/logging any cleanup errors) before returning
the error, ensuring no unpacked snapshots remain; reference the makeClusterData
function and the handler.Cleanup() method used in the deferred cleanup of
clusterData in info.go.
In `@pkg/performanceprofile/profilecreator/cmd/root.go`:
- Around line 158-168: The current code registers the cleanup defer only after
makeNodesHandlers returns nil error, which leaks temp dirs when
makeNodesHandlers fails after creating some handlers; change the call site so
you capture the returned nodesHandlers slice and immediately defer iterating and
calling handler.Cleanup() on any non-nil entries before inspecting err (i.e.,
place the defer right after assigning nodesHandlers, not inside the success
branch), and ensure makeNodesHandlers still returns any partially-created
handlers on error so the deferred cleanup can run (refer to makeNodesHandlers,
nodesHandlers, and handler.Cleanup).
---
Nitpick comments:
In `@pkg/performanceprofile/profilecreator/profilecreator_test.go`:
- Around line 233-235: Add a test that exercises the archive-backed path of
NewGHWHandler by creating a temporary .tgz (or .tar.gz) must-gather archive
containing the same test fixture files used by the directory-backed tests, call
NewGHWHandler with the archive path and the same node input, assert no error,
and ensure DeferCleanup(handle.Cleanup) is used so the failure/cleanup branch in
ghwhandler.go is executed; target the NewGHWHandler call site in
profilecreator_test.go and verify the handler can open and later Cleanup an
archive-backed must-gather to cover the .tgz/.tar.gz branch.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 11279e30-b141-438b-9f4d-8e2265abcdbd
⛔ Files ignored due to path filters (79)
go.sumis excluded by!**/*.sumvendor/github.com/jaypipes/ghw/.gitignoreis excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/Makefileis excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/README.mdis excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/SNAPSHOT.mdis excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/alias.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/host.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/internal/config/context.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/internal/config/log.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/internal/log/log.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator_windows.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard_windows.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/bios/bios.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/bios/bios_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/bios/bios_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/bios/bios_windows.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/block/block.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/block/block_darwin.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/block/block_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/block/block_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/block/block_windows.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/chassis/chassis.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/chassis/chassis_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/chassis/chassis_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/chassis/chassis_windows.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/context/context.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/cpu/cpu.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_darwin.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_windows.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/gpu/gpu.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/gpu/gpu_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/gpu/gpu_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/gpu/gpu_windows.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/linuxdmi/dmi_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/linuxpath/path_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/marshal/marshal.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/memory/memory.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/memory/memory_cache_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/memory/memory_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/memory/memory_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/memory/memory_windows.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/net/net.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/net/net_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/net/net_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/net/net_windows.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/option/option.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/pci/pci.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/pci/pci_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/pci/pci_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/product/product.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/product/product_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/product/product_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/product/product_windows.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_block_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_pci_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_usb_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/snapshot/pack.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/snapshot/trace.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/snapshot/unpack.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/topology/topology.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/topology/topology_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/topology/topology_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/topology/topology_windows.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/usb/usb.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/usb/usb_linux.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/usb/usb_stub.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/jaypipes/ghw/pkg/util/util.gois excluded by!vendor/**,!**/vendor/**vendor/modules.txtis excluded by!vendor/**,!**/vendor/**
📒 Files selected for processing (6)
cmd/gather-sysinfo/gather-sysinfo.gogo.modpkg/performanceprofile/profilecreator/cmd/info.gopkg/performanceprofile/profilecreator/cmd/root.gopkg/performanceprofile/profilecreator/ghwhandler.gopkg/performanceprofile/profilecreator/profilecreator_test.go
Upgrade ghw library and address API breaking changes. The new ghw API no longer provides the WithSnapshot() function and SnapshotOptions struct that were available in versions prior to v0.21.3. Changes: * Update ghwhandler.go to use new snapshot.Unpack() for archive handling * Replace WithSnapshot() with option.WithChroot() for snapshot paths * Add Cleanup() method to GHWHandler for temporary directory cleanup * Handle both .tgz and .tar.gz archive formats explicitly
|
/retest |
|
/retest |
|
@jmencak: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Upgrade ghw library and address API breaking changes. The new ghw API no
longer provides the
WithSnapshot()function andSnapshotOptionsstruct that were available in versions prior to v0.21.3.
Changes:
ghwhandler.goto use newsnapshot.Unpack()for archive handlingWithSnapshot()withoption.WithChroot()for snapshot pathsCleanup()method toGHWHandlerfor temporary directory cleanup.tgzand.tar.gzarchive formats explicitly