Adding support for swap settings#2747
Conversation
|
Please sign your commits following these rules: $ git clone -b "wk8/memory_flags" git@github.com:wk8/swarmkit.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842354427968
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -fAmending updates the existing PR. You DO NOT need to open a new one. |
98af3e7 to
5bd4de6
Compare
5bd4de6 to
dac1258
Compare
Codecov Report
@@ Coverage Diff @@
## master #2747 +/- ##
=========================================
+ Coverage 61.75% 61.9% +0.14%
=========================================
Files 134 134
Lines 21890 21890
=========================================
+ Hits 13518 13550 +32
+ Misses 6905 6884 -21
+ Partials 1467 1456 -11 |
| int64 memory_swap = 27; | ||
|
|
||
| // Tune container memory swappiness (0 to 100) (default -1) | ||
| google.protobuf.Int64Value memory_swappiness = 28; |
There was a problem hiding this comment.
why 0 to 100? nit: maybe add a comment?
There was a problem hiding this comment.
also, curious why Int64Value instead of int64?
There was a problem hiding this comment.
Lazily copied from docker run's help message: --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) :)
There was a problem hiding this comment.
As to Int64Value, stayed consistent with https://github.com/moby/moby/blob/03e089e169a2889f096aceac6ad4a4e2ed6e186b/api/types/container/host_config.go#L333-L334 .
There was a problem hiding this comment.
what's the difference between google.protobuf.Int64Value and the int64 above it? Does it make this compile to *int64 in practice?
There was a problem hiding this comment.
at first, i was 🤔 🤔 🤔 about google.protobuf.Int64Value, but now I see that there is a pretty substantial semantic difference between set and not set for this value, and Int64Value is probably cleaner than a pointer, even if we can hack a pointer into the compiled proto (which we can, I think).
LGTM.
There was a problem hiding this comment.
And even if Int64Value was a pain in the butt, it's not like we do anything with it other than pass it down into the docker engine.
There was a problem hiding this comment.
@anshulpundir "what does (default -1) mean? Where is the default set?" => I guess somewhere deeper in moby?
There was a problem hiding this comment.
Does it make sense to specify that default value here then? What does the default value mean mean to the API consumer?
| map<string, string> sysctls = 26; | ||
|
|
||
| // Swap limit equal to memory plus swap: '-1' to enable unlimited swap | ||
| int64 memory_swap = 27; |
There was a problem hiding this comment.
why do we not need google.protobuf.Int64Value for this field?
There was a problem hiding this comment.
Because that value only needs to be an int64, not a *int64, https://github.com/moby/moby/blob/03e089e169a2889f096aceac6ad4a4e2ed6e186b/api/types/container/host_config.go#L333-L334
There was a problem hiding this comment.
right. if I don't want to change previously set memory swap value, how do I specify that?
Basically, why does memory_swappiness need to be nullable but memory_swap does not?
There was a problem hiding this comment.
"if I don't want to change previously set memory swap value, how do I specify that?" => I think that's the same for all the params here:
- moby's API does expect a full service spec for both creates and updates, you can't just
PATCHan existing service - if your services are created/updated using docker-compose.yml file, then you have all the params in there, and they will all be around when updating
- if you use the CLI, then it's responsible for fetching the current service spec and merging with the new params (https://github.com/docker/cli/blob/master/cli/command/service/update.go#L239-L482); arguably it would be nice to have the API handle that eventually?
So in particular, memory_swappiness doesn't need to be nullable... It just seems good to be consistent with moby's container spec struct?
There was a problem hiding this comment.
ok cool lets move forward as is for consistency.
dac1258 to
53a974e
Compare
6f816f3 to
9c1eb4e
Compare
1fb3a3a to
bc0eadf
Compare
Signed-off-by: Jean Rouge <jer329@cornell.edu>
2ebd05c to
78d9068
Compare
|
LGMT! |
With integration tests Relevant Swarmkit PR: moby/swarmkit#2747 (updated the vendored version of Swarkit to that) Signed-off-by: Jean Rouge <jer329@cornell.edu>
- What I did
API change to support
memory-swapandmemory-swappinesssettings on services- How I did it
Added the two new fields to the protobuf definition
- How to test it
N/A, this is not used in swarkit. Follow-up PR to come on moby/moby
- Description for the changelog
Added support for tuning swap in services. This is equivalent to
docker run's--memory-swapand--memory-swappinessflags.