Skip to content

Commit

Permalink
[cgroups2] Introduce cgroups v2 isolator process.
Browse files Browse the repository at this point in the history
  • Loading branch information
Devin Leamy authored and andreaspeters committed Apr 24, 2024
1 parent 25d24d3 commit 9ca1d18
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 6,401 deletions.
3,004 changes: 0 additions & 3,004 deletions configure.ac

This file was deleted.

3,062 changes: 0 additions & 3,062 deletions src/Makefile.am

This file was deleted.

65 changes: 65 additions & 0 deletions src/slave/containerizer/mesos/isolators/cgroups2/cgroups2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 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 "slave/containerizer/mesos/isolators/cgroups2/cgroups2.hpp"

#include <string>

#include <process/id.hpp>

using mesos::slave::Isolator;

using process::Owned;

using std::string;

namespace mesos {
namespace internal {
namespace slave {

Cgroups2IsolatorProcess::Cgroups2IsolatorProcess(
const hashmap<string, Owned<Subsystem>>& _subsystems)
: ProcessBase(process::ID::generate("cgroups2-isolator")),
subsystems(_subsystems) {}


Cgroups2IsolatorProcess::~Cgroups2IsolatorProcess() {}


Try<Isolator*> Cgroups2IsolatorProcess::create(const Flags& flags)
{
hashmap<string, Owned<Subsystem>> subsystems;

Owned<MesosIsolatorProcess> process(new Cgroups2IsolatorProcess(subsystems));
return new MesosIsolator(process);
}


bool Cgroups2IsolatorProcess::supportsNesting()
{
// TODO(dleamy): Update this once cgroups v2 supports nested containers.
return false;
}


bool Cgroups2IsolatorProcess::supportsStandalone()
{
return true;
}

} // namespace slave {
} // namespace internal {
} // namespace mesos {
59 changes: 59 additions & 0 deletions src/slave/containerizer/mesos/isolators/cgroups2/cgroups2.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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 __CGROUPS_V2_ISOLATOR_HPP__
#define __CGROUPS_V2_ISOLATOR_HPP__

#include <string>

#include <process/owned.hpp>

#include <stout/hashmap.hpp>
#include <stout/hashset.hpp>
#include <stout/try.hpp>

#include "slave/containerizer/mesos/isolator.hpp"
#include "slave/containerizer/mesos/isolators/cgroups/subsystem.hpp"
#include "slave/flags.hpp"

namespace mesos {
namespace internal {
namespace slave {

class Cgroups2IsolatorProcess : public MesosIsolatorProcess
{
public:
static Try<mesos::slave::Isolator*> create(const Flags& flags);

~Cgroups2IsolatorProcess() override;

bool supportsNesting() override;

bool supportsStandalone() override;

private:
Cgroups2IsolatorProcess(
const hashmap<std::string, process::Owned<Subsystem>>& _subsystems);

// Maps each subsystems to the `Subsystem` isolator that manages it.
const hashmap<std::string, process::Owned<Subsystem>> subsystems;
};

} // namespace slave {
} // namespace internal {
} // namespace mesos {

#endif
83 changes: 0 additions & 83 deletions support/mesos-tidy/Dockerfile

This file was deleted.

63 changes: 0 additions & 63 deletions support/mesos-tidy/README.md

This file was deleted.

94 changes: 0 additions & 94 deletions support/mesos-tidy/entrypoint.sh

This file was deleted.

Loading

0 comments on commit 9ca1d18

Please sign in to comment.