Apache Mesos
csi_server.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 __SLAVE_CSI_SERVER_HPP__
18 #define __SLAVE_CSI_SERVER_HPP__
19 
20 #include <string>
21 
22 #include <mesos/mesos.hpp>
23 
25 
27 
28 #include <process/future.hpp>
29 #include <process/http.hpp>
30 #include <process/owned.hpp>
31 
32 #include <stout/hashmap.hpp>
33 #include <stout/try.hpp>
34 
35 #include "csi/service_manager.hpp"
36 #include "csi/volume_manager.hpp"
37 
38 #include "slave/flags.hpp"
39 
40 namespace mesos {
41 namespace internal {
42 namespace slave {
43 
44 class CSIServerProcess;
45 
46 // A CSI server is a collection of volume managers and associated service
47 // managers. This object can be instantiated and held by the Mesos agent to
48 // manage a collection of CSI plugins and proxy calls to them.
49 class CSIServer
50 {
51 public:
52  ~CSIServer();
53 
55  const Flags& flags,
56  const process::http::URL& agentUrl,
57  SecretGenerator* secretGenerator,
58  SecretResolver* secretResolver);
59 
60  // Starts the CSI server. Any `publishVolume()` or `unpublishVolume()` calls
61  // which were made previously will be executed after this method is called.
62  // Returns a future which is satisfied once initialization is complete.
63  process::Future<Nothing> start(const SlaveID& agentId);
64 
65  // Publish a CSI volume to this agent. If the `start()` method has not yet
66  // been called, then the publishing of this volume will not be completed until
67  // the CSI server is started.
68  // Returns the target path at which the volume has been published.
69  process::Future<std::string> publishVolume(const Volume& volume);
70 
71  // Unpublishes a CSI volume from this agent. If the `start()` method has not
72  // yet been called, then the unpublishing of this volume will not be completed
73  // until the CSI server is started.
75  const std::string& pluginName,
76  const std::string& volumeId);
77 
78 private:
79  CSIServer(
80  const process::http::URL& agentUrl,
81  const std::string& rootDir,
82  const std::string& pluginConfigDir,
83  SecretGenerator* secretGenerator,
84  SecretResolver* secretResolver);
85 
87 
89 };
90 
91 } // namespace slave {
92 } // namespace internal {
93 } // namespace mesos {
94 
95 #endif // __SLAVE_CSI_SERVER_HPP__
process::Future< Nothing > unpublishVolume(const std::string &pluginName, const std::string &volumeId)
Definition: check.hpp:33
Definition: csi_server.hpp:49
Definition: flags.hpp:39
process::Future< Nothing > start(const SlaveID &agentId)
Definition: http.hpp:130
Definition: agent.hpp:25
static Try< process::Owned< CSIServer > > create(const Flags &flags, const process::http::URL &agentUrl, SecretGenerator *secretGenerator, SecretResolver *secretResolver)
The SecretGenerator interface represents a mechanism to create a secret from a principal.
Definition: secret_generator.hpp:34
Definition: attributes.hpp:24
Definition: executor.hpp:48
process::Future< std::string > publishVolume(const Volume &volume)
Definition: resolver.hpp:34
Definition: parse.hpp:33