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& resources) override;
67 
69  const ContainerID& containerId) override;
70 
71 private:
73  const Flags& flags,
74  VolumeGidManager* volumeGidManager);
75 
76  const Flags flags;
77  VolumeGidManager* volumeGidManager;
78 
79  struct Info
80  {
81  Info(const std::string& _directory) : directory(_directory) {}
82 
83  Info(const std::string& _directory,
84  const Option<ExecutorInfo>& _executor)
85  : directory(_directory),
86  executor(_executor) {}
87 
88  const std::string directory;
89 
90  // Track resources so we can unmount unneeded persistent volumes.
91  Resources resources;
92 
93  Option<ExecutorInfo> executor;
94  std::vector<gid_t> gids;
95  };
96 
98 
99  struct Metrics
100  {
101  explicit Metrics(
103  ~Metrics();
104 
105  process::metrics::PullGauge containers_new_rootfs;
106  } metrics;
107 
108  double _containers_new_rootfs();
109 };
110 
111 } // namespace slave {
112 } // namespace internal {
113 } // namespace mesos {
114 
115 #endif // __LINUX_FILESYSTEM_ISOLATOR_HPP__
process::Future< Nothing > update(const ContainerID &containerId, const Resources &resources) override
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
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