Apache Mesos
linux.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __LINUX_FILESYSTEM_ISOLATOR_HPP__
18 #define __LINUX_FILESYSTEM_ISOLATOR_HPP__
19 
20 #include <mesos/mesos.hpp>
21 #include <mesos/resources.hpp>
22 
23 #include <process/owned.hpp>
24 #include <process/pid.hpp>
25 
27 
28 #include <stout/hashmap.hpp>
29 
30 #include "slave/flags.hpp"
31 
33 
35 
36 namespace mesos {
37 namespace internal {
38 namespace slave {
39 
40 // The filesystem isolator on Linux that is responsible for preparing
41 // the root filesystems and volumes (e.g., persistent volumes) for
42 // containers. It relies on Linux mount namespace to prevent mounts of
43 // a container from being propagated to the host mount table.
45 {
46 public:
48  const Flags& flags,
49  VolumeGidManager* volumeGidManager = nullptr);
50 
52 
53  bool supportsNesting() override;
54  bool supportsStandalone() override;
55 
57  const std::vector<mesos::slave::ContainerState>& states,
58  const hashset<ContainerID>& orphans) override;
59 
61  const ContainerID& containerId,
62  const mesos::slave::ContainerConfig& containerConfig) override;
63 
65  const ContainerID& containerId,
66  const Resources& resourceRequests,
67  const google::protobuf::Map<
68  std::string, Value::Scalar>& resourceLimits = {}) override;
69 
71  const ContainerID& containerId) override;
72 
73 private:
75  const Flags& flags,
76  VolumeGidManager* volumeGidManager);
77 
78  const Flags flags;
79  VolumeGidManager* volumeGidManager;
80 
81  struct Info
82  {
83  Info(const std::string& _directory) : directory(_directory) {}
84 
85  Info(const std::string& _directory,
86  const Option<ExecutorInfo>& _executor)
87  : directory(_directory),
88  executor(_executor) {}
89 
90  const std::string directory;
91 
92  // Track resources so we can unmount unneeded persistent volumes.
93  Resources resources;
94 
95  Option<ExecutorInfo> executor;
96  std::vector<gid_t> gids;
97  };
98 
100 
101  struct Metrics
102  {
103  explicit Metrics(
105  ~Metrics();
106 
107  process::metrics::PullGauge containers_new_rootfs;
108  } metrics;
109 
110  double _containers_new_rootfs();
111 };
112 
113 } // namespace slave {
114 } // namespace internal {
115 } // namespace mesos {
116 
117 #endif // __LINUX_FILESYSTEM_ISOLATOR_HPP__
process::Future< Option< mesos::slave::ContainerLaunchInfo > > prepare(const ContainerID &containerId, const mesos::slave::ContainerConfig &containerConfig) override
Definition: check.hpp:33
static Try< mesos::slave::Isolator * > create(const Flags &flags, VolumeGidManager *volumeGidManager=nullptr)
process::Future< Nothing > cleanup(const ContainerID &containerId) override
Definition: resources.hpp:83
Definition: volume_gid_manager.hpp:42
Definition: flags.hpp:39
process::Future< Nothing > update(const ContainerID &containerId, const Resources &resourceRequests, const google::protobuf::Map< std::string, Value::Scalar > &resourceLimits={}) override
Definition: hashmap.hpp:38
Definition: pull_gauge.hpp:46
Definition: agent.hpp:25
A "process identifier" used to uniquely identify a process when dispatching messages.
Definition: pid.hpp:289
Definition: attributes.hpp:24
JSON::Object Metrics()
process::Future< Nothing > recover(const std::vector< mesos::slave::ContainerState > &states, const hashset< ContainerID > &orphans) override
Definition: parse.hpp:33