Skip to content

NO-JIRA: Bump ghw dependency#1492

Merged
openshift-merge-bot[bot] merged 3 commits intoopenshift:mainfrom
jmencak:4.22-ghw-bump
Apr 10, 2026
Merged

NO-JIRA: Bump ghw dependency#1492
openshift-merge-bot[bot] merged 3 commits intoopenshift:mainfrom
jmencak:4.22-ghw-bump

Conversation

@jmencak
Copy link
Copy Markdown
Contributor

@jmencak jmencak commented Mar 30, 2026

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

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 30, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Mar 30, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 52edac78-cf25-453c-86ef-9fac203fb609

📥 Commits

Reviewing files that changed from the base of the PR and between bdaba6f and c08fde1.

📒 Files selected for processing (1)
  • cmd/gather-sysinfo/gather-sysinfo.go

Walkthrough

Adds context propagation to snapshot operations, upgrades ghw to v0.23.0, enhances GHWHandler to accept and unpack .tgz/.tar.gz snapshots with temp-dir cleanup, and introduces deferred Cleanup() calls across command code and tests, reporting cleanup errors as warnings.

Changes

Cohort / File(s) Summary
Snapshot Context Propagation
cmd/gather-sysinfo/gather-sysinfo.go
Snapshot operations now use a context (calls to ExpectedCloneContent, CopyFilesInto, PackWithWriter, PackFrom); retrieval of expected clone content now returns a wrapped error; removed conditional debug trace setup; dedupe logic updated to use context-derived file specs.
Dependency Update
go.mod
Bumped github.com/jaypipes/ghw from v0.20.0 to v0.23.0.
Handler Cleanup Patterns
pkg/performanceprofile/profilecreator/cmd/info.go, pkg/performanceprofile/profilecreator/cmd/root.go, pkg/performanceprofile/profilecreator/profilecreator_test.go
Deferred Cleanup() added after handler creation; deferred cleanup iterates handlers and calls handler.Cleanup() on return; cleanup errors are emitted as warnings via Alert/stderr rather than propagated; tests add DeferCleanup/AfterEach hooks to ensure handler Cleanup execution.
GHWHandler Archive Support & Refactor
pkg/performanceprofile/profilecreator/ghwhandler.go
NewGHWHandler detects .tgz/.tar.gz, unpacks archives with snapshot.Unpack and uses the extracted dir as chroot; switched from ghw.WithSnapshot(...) to option.WithChroot(...); snapShotOptions changed from *option.Option to option.Option; added tmpDir field and Cleanup() method to remove temp dirs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

level=error msg="Running error: context loading failed: failed to load packages: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: inconsistent vendoring in :\n\tgithub.com/RHsyseng/operator-utils@v1.4.13: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/coreos/go-systemd@v0.0.0-20191104093116-d3cd4ed1dbcf: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/coreos/ignition@v0.35.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/coreos/ignition/v2@v2.26.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/docker/go-units@v0.5.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/go-logr/stdr@v1.2.2: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/google/go-cmp@v0.7.0

... [truncated 19339 characters] ...

is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tk8s.io/legacy-cloud-providers: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tk8s.io/metrics: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tk8s.io/mount-utils: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tk8s.io/pod-security-admission: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tk8s.io/sample-apiserver: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tgithub.com/onsi/ginkgo/v2: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\n\tTo ignore the vendor directory, use -mod=readonly or -mod=mod.\n\tTo sync the vendor directory, run:\n\t\tgo mod vendor\n"


Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Mar 30, 2026

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 30, 2026
@jmencak
Copy link
Copy Markdown
Contributor Author

jmencak commented Mar 30, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 30, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

makeClusterData errors can still leak unpacked snapshots.

This defer only runs after makeClusterData succeeds. In info mode, a later pool failure can discard handlers already stored for earlier pools without calling Cleanup(), so the temp dirs introduced by archive unpacking are leaked. Please add cleanup inside makeClusterData before 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 | 🟠 Major

Cleanup still misses partial makeNodesHandlers failures.

This defer is registered only after makeNodesHandlers succeeds. 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-backed NewGHWHandler test.

These cleanup additions still only exercise directory-backed must-gather input. The new .tgz/.tar.gz branch and its failure cleanup in ghwhandler.go remain 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d3e91f and 9f1b186.

⛔ Files ignored due to path filters (79)
  • go.sum is excluded by !**/*.sum
  • vendor/github.com/jaypipes/ghw/.gitignore is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/Makefile is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/README.md is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/SNAPSHOT.md is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/alias.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/host.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/internal/config/context.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/internal/config/log.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/internal/log/log.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/bios/bios.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/bios/bios_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/bios/bios_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/bios/bios_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/block/block.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/block/block_darwin.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/block/block_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/block/block_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/block/block_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/chassis/chassis.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/chassis/chassis_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/chassis/chassis_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/chassis/chassis_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/context/context.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/cpu/cpu.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_darwin.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/gpu/gpu.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/gpu/gpu_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/gpu/gpu_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/gpu/gpu_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/linuxdmi/dmi_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/linuxpath/path_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/marshal/marshal.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/memory/memory.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/memory/memory_cache_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/memory/memory_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/memory/memory_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/memory/memory_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/net/net.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/net/net_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/net/net_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/net/net_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/option/option.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/pci/pci.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/pci/pci_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/pci/pci_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/product/product.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/product/product_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/product/product_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/product/product_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_block_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_pci_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_usb_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/pack.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/trace.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/unpack.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/topology/topology.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/topology/topology_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/topology/topology_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/topology/topology_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/usb/usb.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/usb/usb_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/usb/usb_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/util/util.go is excluded by !vendor/**, !**/vendor/**
  • vendor/modules.txt is excluded by !vendor/**, !**/vendor/**
📒 Files selected for processing (6)
  • cmd/gather-sysinfo/gather-sysinfo.go
  • go.mod
  • pkg/performanceprofile/profilecreator/cmd/info.go
  • pkg/performanceprofile/profilecreator/cmd/root.go
  • pkg/performanceprofile/profilecreator/ghwhandler.go
  • pkg/performanceprofile/profilecreator/profilecreator_test.go

Comment thread pkg/performanceprofile/profilecreator/ghwhandler.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
@jmencak jmencak marked this pull request as ready for review March 31, 2026 11:52
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 31, 2026
@openshift-ci openshift-ci Bot requested review from MarSik and yanirq March 31, 2026 11:54
Copy link
Copy Markdown
Contributor

@ffromani ffromani left a comment

Choose a reason for hiding this comment

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

LGTM with some improvements/questions, please see inline comments

Comment thread pkg/performanceprofile/profilecreator/ghwhandler.go
Comment thread pkg/performanceprofile/profilecreator/cmd/info.go Outdated
Comment thread pkg/performanceprofile/profilecreator/cmd/root.go Outdated
Comment thread pkg/performanceprofile/profilecreator/profilecreator_test.go Outdated
Comment thread pkg/performanceprofile/profilecreator/profilecreator_test.go Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 (1)
pkg/performanceprofile/profilecreator/cmd/root.go (1)

158-168: ⚠️ Potential issue | 🟠 Major

Partial handler allocation can leak temp dirs on early failure

Cleanup is deferred only after makeNodesHandlers(...) succeeds. If handler creation fails partway, previously created handlers are not cleaned up.

Proposed fix
 func makeNodesHandlers(mustGatherDirPath, poolName string, nodes []*corev1.Node) ([]*profilecreator.GHWHandler, error) {
 	handlers := make([]*profilecreator.GHWHandler, len(nodes))
 	sb := strings.Builder{}
 	for i, node := range nodes {
 		handle, err := profilecreator.NewGHWHandler(mustGatherDirPath, node)
 		if err != nil {
+			for j := 0; j < i; j++ {
+				if handlers[j] != nil {
+					if cleanupErr := handlers[j].Cleanup(); cleanupErr != nil {
+						Alert("Warning: failed to cleanup handler: %v\n", cleanupErr)
+					}
+				}
+			}
 			return nil, fmt.Errorf("failed to load node's GHW snapshot: %w", err)
 		}
 		handlers[i] = 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 partial allocation of nodesHandlers can leak temp dirs if makeNodesHandlers
returns a non-nil slice and an error; update the error path to cleanup any
handlers already created before returning: after calling
makeNodesHandlers(pcArgs.MustGatherDirPath, pcArgs.NodePoolName, nodes) check if
err != nil and if nodesHandlers != nil iterate over each handler and call
handler.Cleanup() (log warnings on cleanup errors) before returning err; keep
the existing deferred cleanup for the success path (defer loop over
nodesHandlers calling Cleanup) so successful paths remain unchanged.
🧹 Nitpick comments (1)
cmd/gather-sysinfo/gather-sysinfo.go (1)

75-75: Preserve error wrapping when returning the clone-content failure.

Line 75 should use %w so callers can unwrap and classify the underlying error.

Suggested fix
-		return fmt.Errorf("error getting expected clone content: %v", err)
+		return fmt.Errorf("error getting expected clone content: %w", err)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/gather-sysinfo/gather-sysinfo.go` at line 75, The return statement
currently formats the wrapped error with "%v" which prevents callers from
unwrapping; change the fmt.Errorf call that returns "error getting expected
clone content: ..." to use "%w" for the second verb so the underlying error
(err) can be unwrapped by callers (i.e., replace "%v" with "%w" in the
fmt.Errorf call that returns when err != nil while getting expected clone
content).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/gather-sysinfo/gather-sysinfo.go`:
- Line 4: The code creates a detached background context (context.Background())
for snapshot operations so Cobra command cancellation/deadlines aren't
propagated; replace the background context with the command's context by using
cmd.Context() wherever the ctx for snapshot/snapshotter operations is created
(the ctx variable assigned from context.Background() in gather-sysinfo.go) so
downstream calls (snapshot creation/collection) receive cmd.Context() instead of
a detached context.

---

Outside diff comments:
In `@pkg/performanceprofile/profilecreator/cmd/root.go`:
- Around line 158-168: The partial allocation of nodesHandlers can leak temp
dirs if makeNodesHandlers returns a non-nil slice and an error; update the error
path to cleanup any handlers already created before returning: after calling
makeNodesHandlers(pcArgs.MustGatherDirPath, pcArgs.NodePoolName, nodes) check if
err != nil and if nodesHandlers != nil iterate over each handler and call
handler.Cleanup() (log warnings on cleanup errors) before returning err; keep
the existing deferred cleanup for the success path (defer loop over
nodesHandlers calling Cleanup) so successful paths remain unchanged.

---

Nitpick comments:
In `@cmd/gather-sysinfo/gather-sysinfo.go`:
- Line 75: The return statement currently formats the wrapped error with "%v"
which prevents callers from unwrapping; change the fmt.Errorf call that returns
"error getting expected clone content: ..." to use "%w" for the second verb so
the underlying error (err) can be unwrapped by callers (i.e., replace "%v" with
"%w" in the fmt.Errorf call that returns when err != nil while getting expected
clone content).
🪄 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: 073f0507-b1a4-4f73-a1e6-d12cddb591a7

📥 Commits

Reviewing files that changed from the base of the PR and between 9f1b186 and bdaba6f.

⛔ Files ignored due to path filters (79)
  • go.sum is excluded by !**/*.sum
  • vendor/github.com/jaypipes/ghw/.gitignore is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/Makefile is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/README.md is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/SNAPSHOT.md is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/alias.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/host.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/internal/config/context.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/internal/config/log.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/internal/log/log.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/accelerator/accelerator_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/baseboard/baseboard_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/bios/bios.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/bios/bios_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/bios/bios_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/bios/bios_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/block/block.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/block/block_darwin.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/block/block_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/block/block_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/block/block_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/chassis/chassis.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/chassis/chassis_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/chassis/chassis_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/chassis/chassis_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/context/context.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/cpu/cpu.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_darwin.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/cpu/cpu_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/gpu/gpu.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/gpu/gpu_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/gpu/gpu_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/gpu/gpu_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/linuxdmi/dmi_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/linuxpath/path_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/marshal/marshal.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/memory/memory.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/memory/memory_cache_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/memory/memory_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/memory/memory_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/memory/memory_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/net/net.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/net/net_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/net/net_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/net/net_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/option/option.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/pci/pci.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/pci/pci_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/pci/pci_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/product/product.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/product/product_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/product/product_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/product/product_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_block_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_pci_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/clonetree_usb_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/pack.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/trace.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/snapshot/unpack.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/topology/topology.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/topology/topology_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/topology/topology_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/topology/topology_windows.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/usb/usb.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/usb/usb_linux.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/usb/usb_stub.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/jaypipes/ghw/pkg/util/util.go is excluded by !vendor/**, !**/vendor/**
  • vendor/modules.txt is excluded by !vendor/**, !**/vendor/**
📒 Files selected for processing (6)
  • cmd/gather-sysinfo/gather-sysinfo.go
  • go.mod
  • pkg/performanceprofile/profilecreator/cmd/info.go
  • pkg/performanceprofile/profilecreator/cmd/root.go
  • pkg/performanceprofile/profilecreator/ghwhandler.go
  • pkg/performanceprofile/profilecreator/profilecreator_test.go
✅ Files skipped from review due to trivial changes (1)
  • go.mod
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/performanceprofile/profilecreator/cmd/info.go
  • pkg/performanceprofile/profilecreator/ghwhandler.go

Comment thread cmd/gather-sysinfo/gather-sysinfo.go Outdated
node = newTestNode(worker1)
})

AfterEach(func() {
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.

IIRC this can be racy if we run the tests in parallel, which (IIRC again) we don't.

Copy link
Copy Markdown
Contributor

@ffromani ffromani left a comment

Choose a reason for hiding this comment

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

/lgtm

we can merge once coderabbit is happy

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 7, 2026
@jmencak
Copy link
Copy Markdown
Contributor Author

jmencak commented Apr 8, 2026

/retest

1 similar comment
@jmencak
Copy link
Copy Markdown
Contributor Author

jmencak commented Apr 9, 2026

/retest

@jmencak
Copy link
Copy Markdown
Contributor Author

jmencak commented Apr 9, 2026

e2e-hypershift-pao has some infrastructure issues, also see
Also see a dummy PR where this test fails. I'll retry tomorrow, but it should be safe to override this.

@jmencak
Copy link
Copy Markdown
Contributor Author

jmencak commented Apr 9, 2026

/retest

1 similar comment
@jmencak
Copy link
Copy Markdown
Contributor Author

jmencak commented Apr 10, 2026

/retest

@jmencak
Copy link
Copy Markdown
Contributor Author

jmencak commented Apr 10, 2026

/test all

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Apr 10, 2026

PR-Agent: could not fine a component named all in a supported language in this PR.

@jmencak
Copy link
Copy Markdown
Contributor Author

jmencak commented Apr 10, 2026

/test e2e-gcp-pao-updating-profile

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Apr 10, 2026

PR-Agent: could not fine a component named e2e-gcp-pao-updating-profile in a supported language in this PR.

@jmencak jmencak changed the title Bump ghw dependency NO-JIRA: Bump ghw dependency Apr 10, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 10, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@jmencak: This pull request explicitly references no jira issue.

Details

In response to this:

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

Instructions 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 openshift-eng/jira-lifecycle-plugin repository.

@jmencak
Copy link
Copy Markdown
Contributor Author

jmencak commented Apr 10, 2026

/verified by ci/prow/e2e-gcp-pao

ci/prow/e2e-hypershift already passed before

/override ci/prow/e2e-hypershift

ci/prow/e2e-hypershift-pao is an infra issue which has nothing to do with the current PR. Let's get this merged prior the branching.

/override ci/prow/e2e-hypershift-pao

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Apr 10, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@jmencak: This PR has been marked as verified by ci/prow/e2e-gcp-pao.

Details

In response to this:

/verified by ci/prow/e2e-gcp-pao

ci/prow/e2e-hypershift already passed before

/override ci/prow/e2e-hypershift

ci/prow/e2e-hypershift-pao is an infra issue which has nothing to do with the current PR. Let's get this merged prior the branching.

/override ci/prow/e2e-hypershift-pao

Instructions 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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 10, 2026

@jmencak: Overrode contexts on behalf of jmencak: ci/prow/e2e-hypershift, ci/prow/e2e-hypershift-pao

Details

In response to this:

/verified by ci/prow/e2e-gcp-pao

ci/prow/e2e-hypershift already passed before

/override ci/prow/e2e-hypershift

ci/prow/e2e-hypershift-pao is an infra issue which has nothing to do with the current PR. Let's get this merged prior the branching.

/override ci/prow/e2e-hypershift-pao

Instructions 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.

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Apr 10, 2026

PR-Agent: could not fine a component named e2e-hypershift in a supported language in this PR.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 10, 2026

@jmencak: Overrode contexts on behalf of jmencak: ci/prow/e2e-hypershift, ci/prow/e2e-hypershift-pao

Details

In response to this:

/override ci/prow/e2e-hypershift
/override ci/prow/e2e-hypershift-pao

Instructions 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.

@openshift-merge-bot openshift-merge-bot Bot merged commit 3d98f7e into openshift:main Apr 10, 2026
19 checks passed
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 10, 2026

@jmencak: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions 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.

@jmencak jmencak deleted the 4.22-ghw-bump branch April 10, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants