-
Notifications
You must be signed in to change notification settings - Fork 135
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
support cgroup v2 #121
base: master
Are you sure you want to change the base?
support cgroup v2 #121
Conversation
Hi @Curl-Li, welcome to mosn community, Please sign Contributor License Agreement! After you signed CLA, we will automatically sync the status of this pull request in 3 minutes. |
b989991
to
e06c605
Compare
Hi Curl, thanks for your PR, this is a large PR for holmes, I need more time to figure out them, and these changes seems very like automaxprocs/tree/master/internal/cgroups. It seems to be a common solution, but I'm not sure whether it is related to the Golang version |
I referenced part of automaxprocs's code and wrapped it. About issue of version, I tried golang1.9rc1 and golang1.19.1, both are working well. |
LGTM. |
Thanks, I will take a deeper look when I have a long free time. |
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.
Thanks for your nice work. LGTM mostly with a few small comments.
Also, I think it's worth adding comments for the files where copying from.
so that we could easier to trace updates and not break the copyrights.
|
||
if cpuQuota, err = readUint(cgroupCpuQuotaPath); err != nil { | ||
return 0, err | ||
if quota == -1 { |
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.
better add a comment for this -1
.
Also, seems -1
means an error happened, so, maybe return 0 + error
should be better.
if err != nil { | ||
return 0, err | ||
} | ||
limit := uint64(math.Min(float64(usage), float64(machineMemory.Total))) | ||
if usage == -1 { |
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.
ditto.
return 0, err | ||
} | ||
} | ||
quota, _, err := globalCG.CPUQuota() |
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.
I think we should not ignore the _
, otherwise, it may returns -1, nil
, thoughts?
we should check if the _ = true
instead.
return 0, err | ||
} | ||
} | ||
limit, _, err := globalCG.MemLimit() |
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.
ditto.
适配CGroupv2,兼容v1版本,暂未支持混用挂载