-
Notifications
You must be signed in to change notification settings - Fork 2.2k
define MemoryUnlimited const for users #1422
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
Conversation
|
ideally we could have this in the rc and not just master... |
|
@sjenning Could you sign the commit? |
libcontainer/cgroups/fs/memory.go
Outdated
| if cgroup.Resources.Memory == uint64(ulimited) { | ||
| // If the memory update is set to MemoryUnlimited we should also | ||
| // set swap to MemoryUnlimited. | ||
| if cgroup.Resources.Memory == uint64(configs.MemoryUnlimited) { |
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.
With this commit, MemoryUnlimited is defined as a unit64, so I think you can drop the redundant cast from this line (and the later lines which also have uint64(configs.MemoryUnlimited).
31c2e0f to
0d64996
Compare
|
@sjenning "Sign" refers the |
0d64996 to
369f710
Compare
|
@cyphar oops! fixed. |
|
@sjenning Sorry for the confusion. I agree this can be more explicit, but I don't see how Thanks for doing this. |
369f710 to
2a0c037
Compare
|
@hqhq thanks for the review. I've made the requested changes. |
| // Only set swap if it's enbled in kernel | ||
| if cgroups.PathExists(filepath.Join(path, cgroupMemorySwapLimit)) { | ||
| cgroup.Resources.MemorySwap = uint64(ulimited) | ||
| cgroup.Resources.MemorySwap = uint64(configs.MemoryUnlimited) |
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 you dont need to cast this to uint64 anymore
| // for memory and swap memory, so it won't fail because the new | ||
| // value and the old value don't fit kernel's validation. | ||
| if cgroup.Resources.MemorySwap == uint64(ulimited) || memoryUsage.Limit < cgroup.Resources.MemorySwap { | ||
| if cgroup.Resources.MemorySwap == uint64(configs.MemoryUnlimited) || memoryUsage.Limit < cgroup.Resources.MemorySwap { |
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.
same as the above, casting is not necessary.
Signed-off-by: Seth Jennings <[email protected]>
2a0c037 to
5663b26
Compare
| *Resources | ||
| } | ||
|
|
||
| const MemoryUnlimited = math.MaxUint64 |
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.
This is not the value that is actually used by the kernel, which is 9223372036854771712. Some older kernels will set any value larger than this to 0, and then crash, eg RHEL 7.2.
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.
Also this value may well be totally incorrect on 32 bit machines, not sure what happens there.
replace opencontainers#1492 opencontainers#1494 fix opencontainers#1422 Since opencontainers/runtime-spec#876 the memory specifications are now `int64`, as that better matches the visible interface where `-1` is a valid value. Otherwise finding the correct value was difficult as it was kernel dependent. Signed-off-by: Justin Cormack <[email protected]>
replace opencontainers#1492 opencontainers#1494 fix opencontainers#1422 Since opencontainers/runtime-spec#876 the memory specifications are now `int64`, as that better matches the visible interface where `-1` is a valid value. Otherwise finding the correct value was difficult as it was kernel dependent. Signed-off-by: Justin Cormack <[email protected]>
replace opencontainers#1492 opencontainers#1494 fix opencontainers#1422 Since opencontainers/runtime-spec#876 the memory specifications are now `int64`, as that better matches the visible interface where `-1` is a valid value. Otherwise finding the correct value was difficult as it was kernel dependent. Signed-off-by: Justin Cormack <[email protected]> (cherry picked from commit 3d9074e) Signed-off-by: Tibor Vass <[email protected]>
replace opencontainers#1492 opencontainers#1494 fix opencontainers#1422 Since opencontainers/runtime-spec#876 the memory specifications are now `int64`, as that better matches the visible interface where `-1` is a valid value. Otherwise finding the correct value was difficult as it was kernel dependent. Signed-off-by: Justin Cormack <[email protected]> (cherry picked from commit 3d9074e) Signed-off-by: Tibor Vass <[email protected]>
replace opencontainers#1492 opencontainers#1494 fix opencontainers#1422 Since opencontainers/runtime-spec#876 the memory specifications are now `int64`, as that better matches the visible interface where `-1` is a valid value. Otherwise finding the correct value was difficult as it was kernel dependent. Signed-off-by: Justin Cormack <[email protected]>
Fixes #1421
Currently, a user wanting to set
MemorySwapto unlimited has to do a messy trick:as
uint64(-1)doesn't compile.This PR defines a
MemoryUnlimitedconstant to make this cleaner.@derekwaynecarr @mrunalp