This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push:
new e9c25f3d9 [cgroups2] Error if `--cgroups_limit_swap` is used when
cgroups v2 is used.
e9c25f3d9 is described below
commit e9c25f3d9420257d95391de5ca506d6a7a7b3e90
Author: Devin Leamy <[email protected]>
AuthorDate: Fri Apr 19 18:49:12 2024 -0400
[cgroups2] Error if `--cgroups_limit_swap` is used when cgroups v2 is used.
Mesos does not support limiting swap memory when using cgroups v2.
This is because the cgroups v2 API allows separate control of swap usage
and careful consideration is needed to figure out how to limit swap
usage.
Therefore, when the `--cgroups_limit_swap` flag is provided and
cgroups v2 is used we error during flag validation.
This closes #565
---
docs/configuration/agent.md | 3 ++-
src/slave/flags.cpp | 26 ++++++++++++++++++++++++--
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/docs/configuration/agent.md b/docs/configuration/agent.md
index a8286d1b2..832e5c663 100644
--- a/docs/configuration/agent.md
+++ b/docs/configuration/agent.md
@@ -330,7 +330,8 @@ The path to the cgroups hierarchy root. (default:
/sys/fs/cgroup)
</td>
<td>
Cgroups feature flag to enable memory limits on both memory and
-swap instead of just memory. (default: false)
+swap instead of just memory. Not supported if cgroups v2 is used.
+(default: false)
</td>
</tr>
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index 13d71cdd5..151875661 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -37,6 +37,11 @@
#ifdef __linux__
#include "slave/containerizer/mesos/linux_launcher.hpp"
+
+#ifdef ENABLE_CGROUPS_V2
+#include "linux/cgroups2.hpp"
+#endif // ENABLE_CGROUPS_V2
+
#endif // __linux__
#include "slave/containerizer/mesos/provisioner/constants.hpp"
@@ -652,8 +657,25 @@ mesos::internal::slave::Flags::Flags()
add(&Flags::cgroups_limit_swap,
"cgroups_limit_swap",
"Cgroups feature flag to enable memory limits on both memory and\n"
- "swap instead of just memory.\n",
- false);
+ "swap instead of just memory. Not supported if cgroups v2 is used.\n",
+ false,
+ [](const bool& limit_swap) -> Option<Error> {
+#ifdef ENABLE_CGROUPS_V2
+ Try<bool> mounted = cgroups2::mounted();
+ if (mounted.isError()) {
+ return Error("Failed to check if cgroup2 filesystem is mounted: "
+ + mounted.error());
+ }
+
+ // Error if cgroups v2 is being used and a swap limit is requested
+ // as the cgroup v2 isolator does not support limiting swap memory.
+ if (*mounted && limit_swap) {
+ return Error("The cgroups v2 isolator does not support limiting "
+ "swap memory but `--cgroups_limit_swap` was provided");
+ }
+#endif // ENABLE_CGROUPS_V2
+ return None();
+ });
add(&Flags::cgroups_cpu_enable_pids_and_tids_count,
"cgroups_cpu_enable_pids_and_tids_count",