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

commit bcb4a30501e9e459a8b9952a659bd95a9ed0273c
Author: Jason Zhou <[email protected]>
AuthorDate: Thu Aug 8 13:27:57 2024 -0400

    [pids] Introduce the PidsControllerProcess
    
    Introduces the PidsControllerProcess.
    Hosts correctly configured for cgroups v2 and provide cgroups/pids
    in the isolation flag and pids in the agent_subsystems flag
    will use this controller.
    
    Review: https://reviews.apache.org/r/75154
---
 src/CMakeLists.txt                                 |  1 +
 src/Makefile.am                                    |  2 +
 .../mesos/isolators/cgroups2/cgroups2.cpp          |  2 +
 .../mesos/isolators/cgroups2/constants.hpp         |  1 +
 .../mesos/isolators/cgroups2/controllers/pids.cpp  | 49 ++++++++++++++++++++++
 .../mesos/isolators/cgroups2/controllers/pids.hpp  | 46 ++++++++++++++++++++
 6 files changed, 101 insertions(+)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 865daa2fa..b88554ca2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -354,6 +354,7 @@ set(LINUX_SRC
   slave/containerizer/mesos/isolators/cgroups2/controllers/io.cpp
   slave/containerizer/mesos/isolators/cgroups2/controllers/hugetlb.cpp
   slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.cpp
+  slave/containerizer/mesos/isolators/cgroups2/controllers/pids.cpp
   slave/containerizer/device_manager/device_manager.cpp)
 
 if (ENABLE_XFS_DISK_ISOLATOR)
diff --git a/src/Makefile.am b/src/Makefile.am
index 10169fe00..ee1dfc0e7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1508,6 +1508,8 @@ MESOS_LINUX_FILES =                                       
                                \
   slave/containerizer/mesos/isolators/cgroups2/controllers/hugetlb.hpp    \
   slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.cpp    \
   slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.hpp    \
+  slave/containerizer/mesos/isolators/cgroups2/controllers/pids.cpp    \
+  slave/containerizer/mesos/isolators/cgroups2/controllers/pids.hpp    \
   slave/containerizer/device_manager/device_manager.cpp    \
   slave/containerizer/device_manager/device_manager.hpp    \
   slave/containerizer/device_manager/state.hpp
diff --git a/src/slave/containerizer/mesos/isolators/cgroups2/cgroups2.cpp 
b/src/slave/containerizer/mesos/isolators/cgroups2/cgroups2.cpp
index 6434e4533..b28ae7f38 100644
--- a/src/slave/containerizer/mesos/isolators/cgroups2/cgroups2.cpp
+++ b/src/slave/containerizer/mesos/isolators/cgroups2/cgroups2.cpp
@@ -26,6 +26,7 @@
 #include "slave/containerizer/mesos/isolators/cgroups2/controllers/io.hpp"
 #include "slave/containerizer/mesos/isolators/cgroups2/controllers/hugetlb.hpp"
 #include "slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.hpp"
+#include "slave/containerizer/mesos/isolators/cgroups2/controllers/pids.hpp"
 
 #include <set>
 #include <string>
@@ -89,6 +90,7 @@ Try<Isolator*> Cgroups2IsolatorProcess::create(
     {"io", &IoControllerProcess::create}
     {"hugetlb", &HugetlbControllerProcess::create}
     {"cpuset", &CpusetControllerProcess::create}
+    {"pids", &PidsControllerProcess::create}
   };
 
   hashmap<string, Try<Owned<ControllerProcess>>(*)(
diff --git a/src/slave/containerizer/mesos/isolators/cgroups2/constants.hpp 
b/src/slave/containerizer/mesos/isolators/cgroups2/constants.hpp
index 9d7fc5749..1c85c9729 100644
--- a/src/slave/containerizer/mesos/isolators/cgroups2/constants.hpp
+++ b/src/slave/containerizer/mesos/isolators/cgroups2/constants.hpp
@@ -43,6 +43,7 @@ const std::string CGROUPS2_CONTROLLER_DEVICES_NAME = 
"devices";
 const std::string CGROUPS2_CONTROLLER_IO_NAME = "io";
 const std::string CGROUPS2_CONTROLLER_HUGETLB_NAME = "hugetlb";
 const std::string CGROUPS2_CONTROLLER_CPUSET_NAME = "cpuset";
+const std::string CGROUPS2_CONTROLLER_PIDS_NAME = "pids";
 
 } // namespace slave {
 } // namespace internal {
diff --git 
a/src/slave/containerizer/mesos/isolators/cgroups2/controllers/pids.cpp 
b/src/slave/containerizer/mesos/isolators/cgroups2/controllers/pids.cpp
new file mode 100644
index 000000000..d865998b4
--- /dev/null
+++ b/src/slave/containerizer/mesos/isolators/cgroups2/controllers/pids.cpp
@@ -0,0 +1,49 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <process/id.hpp>
+
+#include "slave/containerizer/mesos/isolators/cgroups2/controllers/pids.hpp"
+#include "slave/containerizer/mesos/isolators/cgroups2/constants.hpp"
+
+using process::Owned;
+
+using std::string;
+
+namespace mesos {
+namespace internal {
+namespace slave {
+
+Try<Owned<ControllerProcess>> PidsControllerProcess::create(const Flags& flags)
+{
+  return Owned<ControllerProcess>(new PidsControllerProcess(flags));
+}
+
+
+PidsControllerProcess::PidsControllerProcess(const Flags& _flags)
+  : ProcessBase(process::ID::generate("cgroups-v2-pids-controller")),
+    ControllerProcess(_flags) {}
+
+
+string PidsControllerProcess::name() const
+{
+  return CGROUPS2_CONTROLLER_PIDS_NAME;
+}
+
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
\ No newline at end of file
diff --git 
a/src/slave/containerizer/mesos/isolators/cgroups2/controllers/pids.hpp 
b/src/slave/containerizer/mesos/isolators/cgroups2/controllers/pids.hpp
new file mode 100644
index 000000000..13dcf2b73
--- /dev/null
+++ b/src/slave/containerizer/mesos/isolators/cgroups2/controllers/pids.hpp
@@ -0,0 +1,46 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __PIDS_HPP__
+#define __PIDS_HPP__
+
+#include <string>
+
+#include "slave/containerizer/mesos/isolators/cgroups2/controller.hpp"
+
+namespace mesos {
+namespace internal {
+namespace slave {
+
+class PidsControllerProcess : public ControllerProcess
+{
+public:
+  static Try<process::Owned<ControllerProcess>> create(
+      const Flags& flags);
+
+  ~PidsControllerProcess() override = default;
+
+  std::string name() const override;
+
+private:
+  PidsControllerProcess(const Flags& flags);
+};
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __PIDS_HPP__
\ No newline at end of file

Reply via email to