-
Notifications
You must be signed in to change notification settings - Fork 240
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: return total system memory if the memory limit is not specified #265
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ziwen Ning <[email protected]>
go.mod
Outdated
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/shirou/gopsutil v2.21.11+incompatible // indirect |
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.
gopsutil
is a direct dependency so should be in the first require
clause; go mod tidy
should have put this in the correct place in go.mod
; either way, that is why the CI project check failed.
go.mod
Outdated
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/shirou/gopsutil v2.21.11+incompatible // indirect |
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.
gopsutil
is a direct dependency so should be in the first require
clause; go mod tidy
should have put this in the correct place in go.mod
; either way, that is why the CI project check failed.
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! Fixed. I'm still figuring out how to test it and how to fix v1 so it is in draft.
c53d623
to
37c15a2
Compare
Signed-off-by: Ziwen Ning <[email protected]>
@@ -8,15 +8,22 @@ require ( | |||
github.com/docker/go-units v0.4.0 | |||
github.com/godbus/dbus/v5 v5.0.4 | |||
github.com/opencontainers/runtime-spec v1.0.2 | |||
github.com/shirou/gopsutil/v3 v3.22.12 |
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 hard to implement by ourselves? cgroups is Linux-only whereas gopsutil supports other OSes and brings a bunch of dependencies.
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.
Yeah I can implement it without adding gopsutil.
|
If we change this in containerd, there is not a perfect way to check if the memory is configured. Returning Math.max memory can not only mean the memory is not configured, it can also mean the memory is really set to Math.max (that may be not possible today but may cause issue one day later). Do you think it is ok to use Math.max to check in containerd? Similarily, if other consumers are using Math.max to judge if the memory is configured, they are currently having same defects. So there are a few options below: Option 1 transfer from Math.max to host memory limit in containerd and keep cgroup same. Pros:
Cons:
Option 2 Change default memory limit to host memory limit.
Cons:
Option 3 Change default memory limit to NA in cgroup layer. Containerd and other consumers can transfer to NA to whatever they want (such as host memory limit). Pros:
Cons:
Option 4 Keep cgroup same. Do some refactoring to add additional response field to tell the consumers that the memory limit is not configured. Containerd and other consumers can overwrite the memory limit to whatever they want when the memory limit is not configured Pros:
Cons:
Considering option 2 is not preferred, I'm slightly leaning to Option 4. We can just add a field around here to show if the memory limit is configured. cgroups/cgroup2/stats/metrics.pb.go Line 297 in 157c4da
(Similar for cgroup v1) For the second question, I think we can apply the same option for other limits to keep them consistent. Let me know if you have better ideas. |
I'll give some thought to what might make sense to return here as well, but for the introduction of the new dependency it really should not be needed. It just reads
|
I like Option 1 or Option 4. @AkihiroSuda What do you think? |
@AkihiroSuda WDYT? |
I think this is fine. |
But I agree Option 4 looks better |
Can we just use zero or nil value to indicate that without adding a new field? |
Signed-off-by: Ziwen Ning [email protected]
containerd/nerdctl#1589