You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gi...@apache.org on 2017/12/27 17:33:08 UTC

[2/2] mesos git commit: Added `excluded_images` parameter to `PRUNE_IMAGES` agent API.

Added `excluded_images` parameter to `PRUNE_IMAGES` agent API.

Review: https://reviews.apache.org/r/64812/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/57f37c8e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/57f37c8e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/57f37c8e

Branch: refs/heads/master
Commit: 57f37c8e675e5205e3fa662799ab86f49ad70222
Parents: 213242f
Author: Zhitao Li <zh...@gmail.com>
Authored: Thu Dec 28 01:17:37 2017 +0800
Committer: Gilbert Song <so...@gmail.com>
Committed: Thu Dec 28 01:29:11 2017 +0800

----------------------------------------------------------------------
 include/mesos/agent/agent.proto    | 10 ++++++++++
 include/mesos/v1/agent/agent.proto | 10 ++++++++++
 src/slave/http.cpp                 | 11 ++++++++++-
 3 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/57f37c8e/include/mesos/agent/agent.proto
----------------------------------------------------------------------
diff --git a/include/mesos/agent/agent.proto b/include/mesos/agent/agent.proto
index 756ea6e..3158200 100644
--- a/include/mesos/agent/agent.proto
+++ b/include/mesos/agent/agent.proto
@@ -349,6 +349,14 @@ message Call {
     required string name = 2;
   }
 
+  // Prune unused container images from image store.
+  //
+  // Images and layers referenced by active containers as well as
+  // image references specified in `excluded_images` will not be pruned.
+  message PruneImages {
+    repeated Image excluded_images = 1;
+  }
+
   optional Type type = 1;
 
   optional GetMetrics get_metrics = 2;
@@ -377,6 +385,8 @@ message Call {
   optional AddResourceProviderConfig add_resource_provider_config = 17;
   optional UpdateResourceProviderConfig update_resource_provider_config = 18;
   optional RemoveResourceProviderConfig remove_resource_provider_config = 19;
+
+  optional PruneImages prune_images = 21;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/57f37c8e/include/mesos/v1/agent/agent.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/agent/agent.proto b/include/mesos/v1/agent/agent.proto
index 9c8d3cb..9e8b49d 100644
--- a/include/mesos/v1/agent/agent.proto
+++ b/include/mesos/v1/agent/agent.proto
@@ -349,6 +349,14 @@ message Call {
     required string name = 2;
   }
 
+  // Prune unused container images from image store.
+  //
+  // Images and layers referenced by active containers as well as
+  // image references specified in `excluded_images` will not be pruned.
+  message PruneImages {
+    repeated Image excluded_images = 1;
+  }
+
   optional Type type = 1;
 
   optional GetMetrics get_metrics = 2;
@@ -377,6 +385,8 @@ message Call {
   optional AddResourceProviderConfig add_resource_provider_config = 17;
   optional UpdateResourceProviderConfig update_resource_provider_config = 18;
   optional RemoveResourceProviderConfig remove_resource_provider_config = 19;
+
+  optional PruneImages prune_images = 21;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/57f37c8e/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index d0c1a0c..446be55 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -2447,7 +2447,16 @@ Future<Response> Http::pruneImages(
   // TODO(zhitao): Add AuthN/AuthZ.
 
   LOG(INFO) << "Processing PRUNE_IMAGES call";
-  vector<Image> excludedImages;
+  vector<Image> excludedImages(call.prune_images().excluded_images().begin(),
+                               call.prune_images().excluded_images().end());
+
+  // Include any `excluded_images` from agent flag's `image_gc_config`
+  // if not empty.
+  if (slave->flags.image_gc_config.isSome()) {
+    std::copy(slave->flags.image_gc_config->excluded_images().begin(),
+              slave->flags.image_gc_config->excluded_images().end(),
+              std::back_inserter(excludedImages));
+  }
 
   return slave->containerizer->pruneImages(excludedImages)
       .then([acceptType](const Future<Nothing>& result)