Added an optional agent flag '--image_gc_config'. This is an optional agent flag. If it is not set, it means the automatic container image gc is not enabled. Users have to trigger image gc manually via the operator API. If it is set, the image auto gc is enabled.
Review: https://reviews.apache.org/r/64266 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e9125dd3 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e9125dd3 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e9125dd3 Branch: refs/heads/master Commit: e9125dd3922d7a8b185d86a404105f29c449050c Parents: 5c55770 Author: Gilbert Song <[email protected]> Authored: Wed Nov 22 12:13:05 2017 -0800 Committer: Gilbert Song <[email protected]> Committed: Wed Dec 6 12:04:19 2017 -0800 ---------------------------------------------------------------------- docs/configuration/agent.md | 27 +++++++++++++++++++++++++++ src/messages/flags.hpp | 21 +++++++++++++++++++++ src/slave/flags.cpp | 22 ++++++++++++++++++++++ src/slave/flags.hpp | 1 + 4 files changed, 71 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/e9125dd3/docs/configuration/agent.md ---------------------------------------------------------------------- diff --git a/docs/configuration/agent.md b/docs/configuration/agent.md index 83b0823..d629912 100644 --- a/docs/configuration/agent.md +++ b/docs/configuration/agent.md @@ -875,6 +875,33 @@ Strategy for provisioning container rootfs from images, e.g., <code>aufs</code>, </tr> <tr> <td> + --image_gc_config=VALUE + </td> + <td> +JSON-formatted configuration for automatic container image garbage +collection. This is an optional flag. If it is not set, it means +the automatic container image gc is not enabled. Users have to +trigger image gc manually via the operator API. If it is set, the +auto image gc is enabled. This image gc config can be provided either +as a path pointing to a local file, or as a JSON-formatted string. +Please note that the image garbage collection only work with Mesos +Containerizer for now. +<p/> +See the ImageGcConfig message in `flags.proto` for the expected +format. +<p/> +Example: +<pre><code>{ + "image_disk_headroom": 0.1, + "image_disk_watch_interval": { + "nanoseconds": 3600 + }, + "excluded_images": [] +}</code></pre> + </td> +</tr> +<tr> + <td> --isolation=VALUE </td> <td> http://git-wip-us.apache.org/repos/asf/mesos/blob/e9125dd3/src/messages/flags.hpp ---------------------------------------------------------------------- diff --git a/src/messages/flags.hpp b/src/messages/flags.hpp index 00e26cd..9899987 100644 --- a/src/messages/flags.hpp +++ b/src/messages/flags.hpp @@ -34,6 +34,19 @@ namespace flags { template <> +inline Try<mesos::internal::ImageGcConfig> parse(const std::string& value) +{ + // Convert from string or file to JSON. + Try<JSON::Object> json = parse<JSON::Object>(value); + if (json.isError()) { + return Error(json.error()); + } + + return protobuf::parse<mesos::internal::ImageGcConfig>(json.get()); +} + + +template <> inline Try<mesos::internal::Firewall> parse(const std::string& value) { // Convert from string or file to JSON. @@ -78,6 +91,14 @@ namespace internal { inline std::ostream& operator<<( std::ostream& stream, + const ImageGcConfig& imageGcConfig) +{ + return stream << imageGcConfig.DebugString(); +} + + +inline std::ostream& operator<<( + std::ostream& stream, const Firewall& rules) { return stream << rules.DebugString(); http://git-wip-us.apache.org/repos/asf/mesos/blob/e9125dd3/src/slave/flags.cpp ---------------------------------------------------------------------- diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp index d876474..40b3a43 100644 --- a/src/slave/flags.cpp +++ b/src/slave/flags.cpp @@ -154,6 +154,28 @@ mesos::internal::slave::Flags::Flags() "Strategy for provisioning container rootfs from images,\n" "e.g., `aufs`, `bind`, `copy`, `overlay`."); + add(&Flags::image_gc_config, + "image_gc_config", + "JSON-formatted configuration for automatic container image garbage\n" + "collection. This is an optional flag. If it is not set, it means\n" + "the automatic container image gc is not enabled. Users have to\n" + "trigger image gc manually via the operator API. If it is set, the\n" + "auto image gc is enabled. This image gc config can be provided either\n" + "as a path pointing to a local file, or as a JSON-formatted string.\n" + "Please note that the image garbage collection only work with Mesos\n" + "Containerizer for now." + "\n" + "See the ImageGcConfig message in `flags.proto` for the expected\n" + "format.\n" + "Example:\n" + "{\n" + " \"image_disk_headroom\": 0.1,\n" + " \"image_disk_watch_interval\": {\n" + " \"nanoseconds\": 3600\n" + " },\n" + " \"excluded_images\": []\n" + "}"); + add(&Flags::appc_simple_discovery_uri_prefix, "appc_simple_discovery_uri_prefix", "URI prefix to be used for simple discovery of appc images,\n" http://git-wip-us.apache.org/repos/asf/mesos/blob/e9125dd3/src/slave/flags.hpp ---------------------------------------------------------------------- diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp index f84ba5a..5918484 100644 --- a/src/slave/flags.hpp +++ b/src/slave/flags.hpp @@ -51,6 +51,7 @@ public: Option<std::string> image_providers; Option<std::string> image_provisioner_backend; + Option<ImageGcConfig> image_gc_config; std::string appc_simple_discovery_uri_prefix; std::string appc_store_dir;
