Skip to content
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: disable swap for executor_linux allocations #3958

Merged
merged 2 commits into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ BUG FIXES:
space in it on Windows [[GH-3855](https://github.com/hashicorp/nomad/issues/3855)]
* client/vault: Recognize renewing non-renewable Vault lease as fatal [[GH-3727](https://github.com/hashicorp/nomad/issues/3727)]
* config: Revert minimum CPU limit back to 20 from 100.
* driver/exec: Properly disable swapping [[GH-3958](https://github.com/hashicorp/nomad/issues/3958)]
* driver/lxc: Cleanup LXC containers after errors on container startup. [[GH-3773](https://github.com/hashicorp/nomad/issues/3773)]
* ui: Fix ui on non-leaders when ACLs are enabled [[GH-3722](https://github.com/hashicorp/nomad/issues/3722)]
* ui: Fix requests using client-side certificates in Firefox. [[GH-3728](https://github.com/hashicorp/nomad/pull/3728)]
Expand Down
3 changes: 2 additions & 1 deletion client/driver/executor/executor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ func (e *UniversalExecutor) configureCgroups(resources *structs.Resources) error
// Total amount of memory allowed to consume
e.resConCtx.groups.Resources.Memory = int64(resources.MemoryMB * 1024 * 1024)
// Disable swap to avoid issues on the machine
e.resConCtx.groups.Resources.MemorySwap = int64(-1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to remove this? Is it possible that in some rare situations it may work while the swappiness approach may not?

Copy link
Contributor Author

@fho fho Mar 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to remove this?

Yes

1.) Writing -1 to the memsw.limit_in_bytes file does not disable swap. It sets the limit to unlimited.

NOTE: We can write "-1" to reset the *.limit_in_bytes(unlimited).

https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt
I'll update my commit message accordingly.

2.) It's sufficient to disable swapping via a single mechanism.


Is it possible that in some rare situations it may work while the swappiness approach may not?

Not that I'm aware off. The swappiness value can be set when
CONFIG_MEMCG is enabled and the cggroup memory fs is mounted.
Both are also preconditions for enabling CONFIG_MEMCG_SWAP_ENABLED.

var memSwappiness int64 = 0
e.resConCtx.groups.Resources.MemorySwappiness = &memSwappiness
}

if resources.CPU < 2 {
Expand Down