fix(cpu): Early return for s390x in GetCPUVendor to avoid ghw errors#982
fix(cpu): Early return for s390x in GetCPUVendor to avoid ghw errors#982ashokpariya0 wants to merge 1 commit intok8snetworkplumbingwg:masterfrom
Conversation
On s390x, ghw.CPU() returns empty Processors slice, causing errors and warnings. Add early return based on runtime.GOARCH to skip ghw call and return correct vendor. This keeps existing workflow intact for x86/arm64 while fixing s390x detection Signed-off-by: Ashok Pariya <ashok.pariya@ibm.com>
|
Thanks for your PR,
To skip the vendors CIs, Maintainers can use one of:
|
WalkthroughThe change modifies CPU vendor detection for s390x architecture by adding an early return based on GOARCH instead of deriving it from ghw CPU data. A runtime import was added and the "IBM/S390" case mapping was removed. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/host/internal/cpu/cpu.go (1)
21-27: s390x early return cleanly avoids ghw issuesThe
runtime.GOARCH == "s390x"guard correctly short-circuits ghw on s390x and returnstypes.CPUVendorS390X, matching the PR’s intent and avoiding empty-processor errors while leaving other architectures unchanged. As the codebase accumulates more s390x-specific behavior, you might optionally consider a//go:build s390x-specific implementation file instead of a runtime check, but this is not required for correctness here.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/host/internal/cpu/cpu.go(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/host/internal/cpu/cpu.go (1)
pkg/host/types/interfaces.go (1)
CPUVendorS390X(208-208)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Golangci-lint
- GitHub Check: test
- GitHub Check: test-coverage
- GitHub Check: Analyze (go)
- GitHub Check: build
🔇 Additional comments (1)
pkg/host/internal/cpu/cpu.go (1)
3-9: Runtime import usage is correctThe new
runtimeimport is required for theGOARCHcheck and is properly used, so there’s no unused-import risk.
SchSeba
left a comment
There was a problem hiding this comment.
Hi @ashokpariya0 thanks for the contribution, can I ask if you can add support to the GHW lib?
I think that will be a much better solution.
If that will not be possible (rejected by the package owner) I am fine merging this one
I analyzed the changes needed in the GHW library to add proper CPU info detection(not just vendor_id), and it looks like this will take some time, and we would prefer to handle it in a follow-up PR. For the current use case, we only need the vendor_id, which is fixed for s390 (IBM/S390). We can add something similar to what NFD does (for example: so, i think the existing changes are sufficient for the current case and provide a minimal fix. |
On s390x, ghw.CPU() returns empty Processors slice, causing errors and warnings. Add early return based on runtime.GOARCH to skip ghw call and return correct vendor.
This keeps existing workflow intact for x86/arm64 while fixing s390x detection.
Why we need this change??
We use ghw library(https://github.com/jaypipes/ghw) for cpu vendor detection which does not support s390x arch.
sriov-network-operator/pkg/host/internal/cpu/cpu.go
Line 21 in 2f98be3
and we see below warning/error in generic plugin log
This is because it expect vendor_id in /proc/cpuinfo which is not available in s390x case like below
On s390x, the format is different (global vendor_id, # processors, then per-processor blocks with cpu number, book id, drawer id)
ghw fails to parse processors and returns empty Processors slice
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.