-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix getProcessCpuStat return value (in percentage) breaks compatibility. #540
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #540 +/- ##
==========================================
+ Coverage 53.17% 53.25% +0.08%
==========================================
Files 91 91
Lines 5894 5896 +2
==========================================
+ Hits 3134 3140 +6
+ Misses 2413 2408 -5
- Partials 347 348 +1
☔ View full report in Codecov by Sentry. |
Hi @binbin0325 @sczyh30, looking forward to your reply. |
@@ -176,6 +177,10 @@ func retrieveAndUpdateCpuStat() { | |||
return | |||
} | |||
|
|||
// fix getProcessCpuStat return value (in percentage) breaks compatibility. | |||
cpuNum := runtime.NumCPU() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it for CPU requests or CPU limits under container env?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How this works in container?
Hi @sczyh30 @binbin0325, if there are no doubts, we look forward to the adoption of PR |
Hi @sczyh30 @binbin0325, looking forward to your reply |
Hi @sczyh30 @binbin0325, looking forward to your reply |
@@ -176,6 +177,10 @@ func retrieveAndUpdateCpuStat() { | |||
return | |||
} | |||
|
|||
// fix getProcessCpuStat return value (in percentage) breaks compatibility. | |||
cpuNum := runtime.NumCPU() | |||
cpuPercent = cpuPercent / float64(cpuNum) / 100.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we divide by cpuNum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确实不应该除以 cpuNum 直接取百分比就好
Describe what this PR does / why we need it
fix getProcessCpuStat return value (in percentage) breaks compatibility.
Does this pull request fix one issue?
Fix #539
Describe how you did it
fix the bug that the CPU usage from getProcessCpuStat was changed to percentage value (i.e. 0-100), which breaks compatibility and affects system adaptive rules.
Describe how to verify it
Added a unit test
func TestRetrieveAndUpdateCpuStatReturnValueRange(t *testing.T)
Special notes for reviews