DevinLeamy commented on code in PR #539:
URL: https://github.com/apache/mesos/pull/539#discussion_r1543255754
##########
src/slave/main.cpp:
##########
@@ -406,13 +541,29 @@ int main(int argc, char** argv)
}
#ifdef __linux__
- // Move the agent process into its own cgroup for each of the specified
- // subsystems if necessary before the process is initialized.
if (flags.agent_subsystems.isSome()) {
- Try<Nothing> assign = assignCgroups(flags);
- if (assign.isError()) {
- EXIT(EXIT_FAILURE) << assign.error();
- }
+ // Use the cgroups v2 isolator if it is supported. Otherwise, use
+ // the cgroups v1 isolator.
+ do {
+ #ifdef ENABLE_CGROUPS_V2
+ Try<bool> supported = slave::cgroups2_isolator::supported();
+
+ if (supported.isSome() && *supported) {
+ Try<Nothing> initCgroups2 = initializeCgroups2(flags);
+ if (initCgroups2.isError()) {
+ EXIT(EXIT_FAILURE) << initCgroups2.error();
+ }
+
+ break;
+ }
+ #endif // ENABLE_CGROUPS_V2
+ // Move the agent process into its own cgroup for each of the specified
+ // subsystems if necessary before the process is initialized.
+ Try<Nothing> assign = assignCgroups(flags);
+ if (assign.isError()) {
+ EXIT(EXIT_FAILURE) << assign.error();
+ }
+ } while (false);
Review Comment:
The `do-while` here looks a little weird, but it's so we can `break` out of
the block if cgroups v2 is supported, to avoid having to copy to cgroups v1
initialization code. There's a few things we could do:
1. Put this in a function.
2. Have the if-elses.
3. Something else.
Happy to update this if there's a nicer approach.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]