Apache Mesos
isolator.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 __VOLUME_CSI_ISOLATOR_HPP__
18 #define __VOLUME_CSI_ISOLATOR_HPP__
19 
20 #include <string>
21 #include <vector>
22 
23 #include <mesos/mesos.hpp>
24 
25 #include <process/future.hpp>
26 #include <process/id.hpp>
27 #include <process/process.hpp>
28 
29 #include <stout/hashset.hpp>
30 #include <stout/nothing.hpp>
31 #include <stout/option.hpp>
32 #include <stout/try.hpp>
33 
34 #include "slave/csi_server.hpp"
35 #include "slave/flags.hpp"
36 
38 
40 
41 namespace mesos {
42 namespace internal {
43 namespace slave {
44 
46 {
47 public:
49  const Flags& flags,
50  CSIServer* csiServer);
51 
53 
54  bool supportsNesting() 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) override;
66 
67 private:
68  struct Mount
69  {
70  Volume volume;
71  CSIVolume csiVolume;
72  std::string target;
73  };
74 
75  struct Info
76  {
77  Info (const hashset<CSIVolume>& _volumes)
78  : volumes(_volumes) {}
79 
80  hashset<CSIVolume> volumes;
81  };
82 
84  const Flags& _flags,
85  CSIServer* _csiServer,
86  const std::string& _rootDir)
87  : ProcessBase(process::ID::generate("volume-csi-isolator")),
88  flags(_flags),
89  csiServer(_csiServer),
90  rootDir(_rootDir) {}
91 
93  const ContainerID& containerId,
94  const std::vector<Mount>& mounts,
96  const std::vector<process::Future<std::string>>& futures);
97 
98  process::Future<Nothing> _cleanup(
99  const ContainerID& containerId,
100  const std::vector<process::Future<Nothing>>& futures);
101 
102  Try<Nothing> recoverContainer(const ContainerID& containerId);
103 
104  const Flags flags;
105  CSIServer* csiServer;
106 
107  // CSI volume information root directory.
108  const std::string rootDir;
109 
111 };
112 
113 } // namespace slave {
114 } // namespace internal {
115 } // namespace mesos {
116 
117 #endif // __VOLUME_CSI_ISOLATOR_HPP__
std::string generate(const std::string &prefix="")
Returns &#39;prefix(N)&#39; where N represents the number of instances where the same prefix (wrt...
process::Future< Nothing > recover(const std::vector< mesos::slave::ContainerState > &states, const hashset< ContainerID > &orphans) override
ProcessBase(const std::string &id="")
Definition: check.hpp:33
~VolumeCSIIsolatorProcess() override
Definition: isolator.hpp:52
Result< std::string > user(Option< uid_t > uid=None())
Definition: su.hpp:284
Definition: csi_server.hpp:49
process::Future< Nothing > cleanup(const ContainerID &containerId) override
Definition: flags.hpp:39
Definition: hashmap.hpp:38
Volume::Source::CSIVolume CSIVolume
Definition: v0_utils.hpp:33
Definition: agent.hpp:25
process::Future< Option< mesos::slave::ContainerLaunchInfo > > prepare(const ContainerID &containerId, const mesos::slave::ContainerConfig &containerConfig) override
static Try< mesos::slave::Isolator * > create(const Flags &flags, CSIServer *csiServer)
Definition: attributes.hpp:24
Definition: parse.hpp:33