17 #ifndef __DOCKER_CONTAINERIZER_HPP__ 18 #define __DOCKER_CONTAINERIZER_HPP__ 64 class DockerContainerizerProcess;
93 const ContainerID& containerId,
94 const mesos::slave::ContainerConfig& containerConfig,
95 const std::map<std::string, std::string>&
environment,
99 const ContainerID& containerId,
101 const google::protobuf::Map<
102 std::string, Value::Scalar>& resourceLimits = {})
override;
105 const ContainerID& containerId)
override;
108 const ContainerID& containerId)
override;
111 const ContainerID& containerId)
override;
114 const ContainerID& containerId)
override;
119 const std::vector<Image>& excludedImages)
override;
147 const ContainerID& containerId,
148 const mesos::slave::ContainerConfig& containerConfig,
149 const std::map<std::string, std::string>&
environment,
155 const ContainerID& containerId,
157 const google::protobuf::Map<std::string, Value::Scalar>& resourceLimits,
161 const ContainerID& containerId);
164 const ContainerID& containerId);
167 const ContainerID& containerId);
170 const ContainerID& containerId,
182 Metrics() : image_pull(
"containerizer/docker/image_pull",
Hours(1))
197 const ContainerID& containerId,
201 const ContainerID& containerId,
205 const ContainerID& containerId,
206 const mesos::slave::ContainerConfig& containerConfig);
210 const std::vector<Docker::Container>& containers);
213 const std::vector<Docker::Container>& containers);
217 const ContainerID& containerId,
218 const std::string& containerName);
222 const ContainerID& containerId);
225 const ContainerID& containerId,
230 const ContainerID& containerId,
234 const ContainerID& containerId,
238 const ContainerID& containerId,
243 const ContainerID& containerId,
248 const ContainerID& containerId,
253 const ContainerID& containerId,
258 const ContainerID& containerId,
260 const google::protobuf::Map<std::string, Value::Scalar>& resourceLimits,
264 const ContainerID& containerId,
266 const google::protobuf::Map<std::string, Value::Scalar>& resourceLimits);
270 const ContainerID& containerId);
273 const ContainerID& containerId);
276 const ContainerID& containerId,
277 const std::string& directory,
284 const ContainerID& containerId,
288 const ContainerID& containerId,
289 const std::set<Gpu>& allocated);
293 const ContainerID& containerId);
296 const ContainerID& containerId,
297 const std::set<Gpu>& deallocated);
304 void reaped(
const ContainerID& containerId);
308 const std::string& containerName,
326 const ContainerID&
id,
327 const mesos::slave::ContainerConfig& containerConfig,
328 const std::map<std::string, std::string>& environment,
332 static std::string
name(
const ContainerID&
id)
334 return DOCKER_NAME_PREFIX +
stringify(
id);
337 Container(
const ContainerID&
id)
338 : state(FETCHING), id(
id) {}
341 const ContainerID& _id,
342 const mesos::slave::ContainerConfig& _containerConfig,
343 const std::map<std::string, std::string>& _environment,
346 const std::string& containerWorkDir,
349 bool launchesExecutorContainer)
352 containerConfig(_containerConfig),
353 pidCheckpointPath(_pidCheckpointPath),
355 symlinked(symlinked),
356 containerWorkDir(containerWorkDir),
357 containerName(
name(
id)),
358 launchesExecutorContainer(launchesExecutorContainer),
359 generatedForCommandTask(_containerConfig.has_task_info())
371 resourceRequests = containerConfig.resources();
372 resourceLimits = containerConfig.limits();
374 if (containerConfig.has_task_info()) {
376 resourceRequests.
contains(containerConfig.task_info().resources()));
380 command = _command.
get();
382 command = containerConfig.command_info();
385 if (_container.
isSome()) {
386 container = _container.
get();
390 container = containerConfig.container_info();
405 if (launchesExecutorContainer) {
406 return containerName + DOCKER_NAME_SEPERATOR +
"executor";
412 std::string
image()
const 414 if (containerConfig.has_task_info()) {
415 return containerConfig.task_info().container().docker().image();
418 return containerConfig.executor_info().container().docker().image();
421 bool forcePullImage()
const 423 if (containerConfig.has_task_info()) {
424 return containerConfig.task_info()
425 .container().docker().force_pull_image();
428 return containerConfig.executor_info()
429 .container().docker().force_pull_image();
465 const ContainerID id;
466 const mesos::slave::ContainerConfig containerConfig;
479 std::string containerWorkDir;
484 ContainerInfo container;
495 std::string containerName;
514 google::protobuf::Map<std::string, Value::Scalar> resourceLimits;
539 bool launchesExecutorContainer;
541 bool generatedForCommandTask;
552 #endif // __DOCKER_CONTAINERIZER_HPP__ Try< Nothing > checkpoint(const std::string &path, const std::string &message, bool sync, bool downgradeResources)
Definition: state.hpp:123
Definition: option.hpp:29
Try< Nothing > rm(const std::string &path)
Definition: rm.hpp:26
Future< Nothing > remove(const Metric &metric)
Definition: metrics.hpp:109
Definition: fetcher.hpp:49
process::Future< Nothing > recover(const Option< state::SlaveState > &state) override
Definition: docker.hpp:67
process::Future< ContainerStatus > status(const ContainerID &containerId) override
process::Future< Nothing > update(const ContainerID &containerId, const Resources &resourceRequests, const google::protobuf::Map< std::string, Value::Scalar > &resourceLimits={}) override
Definition: resources.hpp:83
Definition: docker.hpp:127
process::Future< hashset< ContainerID > > containers() override
Try< T > fetch(const std::string &value)
Definition: fetch.hpp:38
process::Future< Option< mesos::slave::ContainerTermination > > destroy(const ContainerID &containerId) override
Future< Nothing > add(const T &metric)
Definition: metrics.hpp:95
bool isSome() const
Definition: option.hpp:116
Definition: docker.hpp:91
Environment * environment
DWORD pid_t
Definition: windows.hpp:181
process::Future< Containerizer::LaunchResult > launch(const ContainerID &containerId, const mesos::slave::ContainerConfig &containerConfig, const std::map< std::string, std::string > &environment, const Option< std::string > &pidCheckpointPath) override
Definition: containerizer.hpp:64
DockerContainerizer(const Flags &flags, Fetcher *fetcher, const process::Owned< mesos::slave::ContainerLogger > &logger, process::Shared< Docker > docker, const Option< NvidiaComponents > &nvidia=None())
process::Future< ResourceStatistics > usage(const ContainerID &containerId) override
const T & get() const &
Definition: option.hpp:119
const std::string DOCKER_NAME_PREFIX
process::Future< Nothing > pruneImages(const std::vector< Image > &excludedImages) override
Definition: duration.hpp:235
#define flags
Definition: decoder.hpp:18
~DockerContainerizer() override
URI image(const std::string &repository, const std::string &reference, const std::string ®istry, const Option< std::string > &scheme=None(), const Option< int > &port=None())
Definition: docker.hpp:30
Definition: attributes.hpp:24
const std::string DOCKER_SYMLINK_DIRECTORY
Definition: executor.hpp:48
std::string stringify(int flags)
const std::string DOCKER_NAME_SEPERATOR
bool contains(const Resources &that) const
Definition: process.hpp:505
DockerContainerizerProcess(const Flags &_flags, Fetcher *_fetcher, const process::Owned< mesos::slave::ContainerLogger > &_logger, process::Shared< Docker > _docker, const Option< NvidiaComponents > &_nvidia)
Definition: docker.hpp:131
PID< MetricsProcess > metrics
constexpr const char * name
Definition: shell.hpp:41
static Try< DockerContainerizer * > create(const Flags &flags, Fetcher *fetcher, const Option< NvidiaComponents > &nvidia=None())
process::Future< Option< mesos::slave::ContainerTermination > > wait(const ContainerID &containerId) override