You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/12/09 02:54:54 UTC

[7/7] mesos git commit: Added operator API to update and remove resource provider configs.

Added operator API to update and remove resource provider configs.

This patch addes API calls to add, update and remove config files for
local resource providers, and asynchronously reload or terminates them.

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


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

Branch: refs/heads/master
Commit: 1088a54ebb76987bb5bc4da02e03df99cf1f09ad
Parents: ec4560e
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Fri Dec 8 18:12:23 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 8 18:54:43 2017 -0800

----------------------------------------------------------------------
 include/mesos/agent/agent.proto    | 62 +++++++++++++++++++++++++++++++++
 include/mesos/v1/agent/agent.proto | 62 +++++++++++++++++++++++++++++++++
 src/slave/validation.cpp           | 37 ++++++++++++++++++++
 3 files changed, 161 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1088a54e/include/mesos/agent/agent.proto
----------------------------------------------------------------------
diff --git a/include/mesos/agent/agent.proto b/include/mesos/agent/agent.proto
index eb5f1b4..d464afe 100644
--- a/include/mesos/agent/agent.proto
+++ b/include/mesos/agent/agent.proto
@@ -89,6 +89,10 @@ message Call {
     WAIT_CONTAINER = 23;   // See 'WaitContainer' below.
     KILL_CONTAINER = 24;   // See 'KillContainer' below.
     REMOVE_CONTAINER = 25; // See 'RemoveContainer' below.
+
+    ADD_RESOURCE_PROVIDER_CONFIG = 27;    // See 'AddResourceProviderConfig' below. // NOLINT
+    UPDATE_RESOURCE_PROVIDER_CONFIG = 28; // See 'UpdateResourceProviderConfig' below. // NOLINT
+    REMOVE_RESOURCE_PROVIDER_CONFIG = 29; // See 'RemoveResourceProviderConfig' below. // NOLINT
   }
 
   // Provides a snapshot of the current metrics tracked by the agent.
@@ -282,6 +286,60 @@ message Call {
     required ContainerID container_id = 1;
   }
 
+  // Adds a new resource provider config file.
+  //
+  // The content of the 'info' field will be written into a new config
+  // file in the resource provider config directory. The 'info.id' field
+  // should not be set. A resource provider will be launched based on
+  // the new config asynchronously. Note that only config files that
+  // exist at agent startup will be checked against this call.
+  //
+  // Returns 200 OK if a new config file is created.
+  // Returns 400 Bad Request if 'info' is not well-formed.
+  // Returns 403 Forbidden if the call is not authorized.
+  // Returns 409 Conflict if another config file that describes a
+  //   resource provider of the same type and name exists.
+  // Returns 500 Internal Server Error if anything goes wrong.
+  message AddResourceProviderConfig {
+    required ResourceProviderInfo info = 1;
+  }
+
+  // Updates an existing resource provider config file.
+  //
+  // The content of the 'info' field  will be written into an existing
+  // config file that describes a resource provider of the specified
+  // type and name in the resource provider config directory. The
+  // 'info.id' field should not be set. The resource provider will be
+  // relaunched asynchoronously to reflect the changes in its config.
+  // Note that only config files that exist at agent startup can be
+  // updated though this call.
+  //
+  // Returns 200 OK if an existing config file is updated.
+  // Returns 400 Bad Request if 'info' is not well-formed.
+  // Returns 403 Forbidden if the call is not authorized.
+  // Returns 404 Not Found if no config file describes a resource
+  //  provider of the same type and name exists.
+  // Returns 500 Internal Server Error if anything goes wrong.
+  message UpdateResourceProviderConfig {
+    required ResourceProviderInfo info = 1;
+  }
+
+  // Removes a config file from the resource provider config directory.
+  //
+  // The config file that describes the resource provider of the
+  // specified type and name will be removed. The resource provider will
+  // be terminated asynchronously. Note that only config files that
+  // exists at agent startup can be removed though this call.
+  //
+  // Returns 200 OK if the config file is removed.
+  // Returns 403 Forbidden if the call is not authorized.
+  // Returns 404 Not Found if the config file does not exist.
+  // Returns 500 Internal Server Error if anything goes wrong.
+  message RemoveResourceProviderConfig {
+    required string type = 1;
+    required string name = 2;
+  }
+
   optional Type type = 1;
 
   optional GetMetrics get_metrics = 2;
@@ -304,6 +362,10 @@ message Call {
   optional WaitContainer wait_container = 14;
   optional KillContainer kill_container = 15;
   optional RemoveContainer remove_container = 16;
+
+  optional UpdateResourceProviderConfig add_resource_provider_config = 17;
+  optional UpdateResourceProviderConfig update_resource_provider_config = 18;
+  optional RemoveResourceProviderConfig remove_resource_provider_config = 19;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/1088a54e/include/mesos/v1/agent/agent.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/agent/agent.proto b/include/mesos/v1/agent/agent.proto
index 3aedfe8..91fe5e1 100644
--- a/include/mesos/v1/agent/agent.proto
+++ b/include/mesos/v1/agent/agent.proto
@@ -89,6 +89,10 @@ message Call {
     WAIT_CONTAINER = 23;   // See 'WaitContainer' below.
     KILL_CONTAINER = 24;   // See 'KillContainer' below.
     REMOVE_CONTAINER = 25; // See 'RemoveContainer' below.
+
+    ADD_RESOURCE_PROVIDER_CONFIG = 27;    // See 'AddResourceProviderConfig' below. // NOLINT
+    UPDATE_RESOURCE_PROVIDER_CONFIG = 28; // See 'UpdateResourceProviderConfig' below. // NOLINT
+    REMOVE_RESOURCE_PROVIDER_CONFIG = 29; // See 'RemoveResourceProviderConfig' below. // NOLINT
   }
 
   // Provides a snapshot of the current metrics tracked by the agent.
@@ -282,6 +286,60 @@ message Call {
     required ContainerID container_id = 1;
   }
 
+  // Adds a new resource provider config file.
+  //
+  // The content of the 'info' field will be written into a new config
+  // file in the resource provider config directory. The 'info.id' field
+  // should not be set. A resource provider will be launched based on
+  // the new config asynchronously. Note that only config files that
+  // exist at agent startup will be checked against this call.
+  //
+  // Returns 200 OK if a new config file is created.
+  // Returns 400 Bad Request if 'info' is not well-formed.
+  // Returns 403 Forbidden if the call is not authorized.
+  // Returns 409 Conflict if another config file that describes a
+  //   resource provider of the same type and name exists.
+  // Returns 500 Internal Server Error if anything goes wrong.
+  message AddResourceProviderConfig {
+    required ResourceProviderInfo info = 1;
+  }
+
+  // Updates an existing resource provider config file.
+  //
+  // The content of the 'info' field  will be written into an existing
+  // config file that describes a resource provider of the specified
+  // type and name in the resource provider config directory. The
+  // 'info.id' field should not be set. The resource provider will be
+  // relaunched asynchoronously to reflect the changes in its config.
+  // Note that only config files that exist at agent startup can be
+  // updated though this call.
+  //
+  // Returns 200 OK if an existing config file is updated.
+  // Returns 400 Bad Request if 'info' is not well-formed.
+  // Returns 403 Forbidden if the call is not authorized.
+  // Returns 404 Not Found if no config file describes a resource
+  //  provider of the same type and name exists.
+  // Returns 500 Internal Server Error if anything goes wrong.
+  message UpdateResourceProviderConfig {
+    required ResourceProviderInfo info = 1;
+  }
+
+  // Removes a config file from the resource provider config directory.
+  //
+  // The config file that describes the resource provider of the
+  // specified type and name will be removed. The resource provider will
+  // be terminated asynchronously. Note that only config files that
+  // exists at agent startup can be removed though this call.
+  //
+  // Returns 200 OK if the config file is removed.
+  // Returns 403 Forbidden if the call is not authorized.
+  // Returns 404 Not Found if the config file does not exist.
+  // Returns 500 Internal Server Error if anything goes wrong.
+  message RemoveResourceProviderConfig {
+    required string type = 1;
+    required string name = 2;
+  }
+
   optional Type type = 1;
 
   optional GetMetrics get_metrics = 2;
@@ -304,6 +362,10 @@ message Call {
   optional WaitContainer wait_container = 14;
   optional KillContainer kill_container = 15;
   optional RemoveContainer remove_container = 16;
+
+  optional UpdateResourceProviderConfig add_resource_provider_config = 17;
+  optional UpdateResourceProviderConfig update_resource_provider_config = 18;
+  optional RemoveResourceProviderConfig remove_resource_provider_config = 19;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/1088a54e/src/slave/validation.cpp
----------------------------------------------------------------------
diff --git a/src/slave/validation.cpp b/src/slave/validation.cpp
index 4a3a78a..17cabd1 100644
--- a/src/slave/validation.cpp
+++ b/src/slave/validation.cpp
@@ -488,6 +488,43 @@ Option<Error> validate(
 
       return None();
     }
+
+    case mesos::agent::Call::ADD_RESOURCE_PROVIDER_CONFIG: {
+      if (!call.has_add_resource_provider_config()) {
+        return Error(
+            "Expecting 'add_resource_provider_config' to be present");
+      }
+
+      if (call.add_resource_provider_config().info().has_id()) {
+        return Error(
+            "Expecting 'add_resource_provider_config.info.id' to be unset");
+      }
+
+      return None();
+    }
+
+    case mesos::agent::Call::UPDATE_RESOURCE_PROVIDER_CONFIG: {
+      if (!call.has_update_resource_provider_config()) {
+        return Error(
+            "Expecting 'update_resource_provider_config' to be present");
+      }
+
+      if (call.update_resource_provider_config().info().has_id()) {
+        return Error(
+            "Expecting 'update_resource_provider_config.info.id' to be unset");
+      }
+
+      return None();
+    }
+
+    case mesos::agent::Call::REMOVE_RESOURCE_PROVIDER_CONFIG: {
+      if (!call.has_remove_resource_provider_config()) {
+        return Error(
+            "Expecting 'remove_resource_provider_config' to be present");
+      }
+
+      return None();
+    }
   }
 
   UNREACHABLE();