You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/03/25 22:48:35 UTC

mesos git commit: Change Call and Event Type enums in executor.proto optional.

Repository: mesos
Updated Branches:
  refs/heads/master f0191b255 -> 40fd5672c


Change Call and Event Type enums in executor.proto optional.

This fix changes Call and Event Type enums in executor.proto
from required to optional for the purpose of backwards compatibility.

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


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

Branch: refs/heads/master
Commit: 40fd5672ccb580b757690064e0d30ac33841fbc0
Parents: f0191b2
Author: Yong Tang <yo...@outlook.com>
Authored: Fri Mar 25 14:47:44 2016 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Mar 25 14:48:25 2016 -0700

----------------------------------------------------------------------
 CHANGELOG                                |  3 +++
 include/mesos/executor/executor.proto    | 15 +++++++++++++--
 include/mesos/v1/executor/executor.proto | 15 +++++++++++++--
 src/examples/test_http_executor.cpp      |  4 ++++
 src/slave/validation.cpp                 |  4 ++++
 src/tests/mesos.hpp                      |  2 ++
 6 files changed, 39 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/40fd5672/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index cd551d8..4c73a26 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -35,6 +35,9 @@ Additional API Changes:
   * [MESOS-5014] - Changes Call and Event Type enums in scheduler.proto
     from required to optional for the purpose of backwards compatibility.
 
+  * [MESOS-5015] - Changes Call and Event Type enums in executor.proto
+    from required to optional for the purpose of backwards compatibility.
+
 
 Release Notes - Mesos - Version 0.28.0
 --------------------------------------------

http://git-wip-us.apache.org/repos/asf/mesos/blob/40fd5672/include/mesos/executor/executor.proto
----------------------------------------------------------------------
diff --git a/include/mesos/executor/executor.proto b/include/mesos/executor/executor.proto
index 6b4141f..338b363 100644
--- a/include/mesos/executor/executor.proto
+++ b/include/mesos/executor/executor.proto
@@ -32,6 +32,12 @@ message Event {
   // Possible event types, followed by message definitions if
   // applicable.
   enum Type {
+    // This must be the first enum value in this list, to
+    // ensure that if 'type' is not set, the default value
+    // is UNKNOWN. This enables enum values to be added
+    // in a backwards-compatible way. See: MESOS-4997.
+    UNKNOWN = 0;
+
     SUBSCRIBED = 1;   // See 'Subscribed' below.
     LAUNCH = 2;       // See 'Launch' below.
     KILL = 3;         // See 'Kill' below.
@@ -113,7 +119,8 @@ message Event {
 
   // Type of the event, indicates which optional field below should be
   // present if that type has a nested message definition.
-  required Type type = 1;
+  // Enum fields should be optional, see: MESOS-4997.
+  optional Type type = 1;
 
   optional Subscribed subscribed = 2;
   optional Acknowledged acknowledged = 3;
@@ -134,6 +141,9 @@ message Event {
   // Possible call types, followed by message definitions if
   // applicable.
   enum Type {
+    // See comments above on `Event::Type` for more details on this enum value.
+    UNKNOWN = 0;
+
     SUBSCRIBE = 1;    // See 'Subscribe' below.
     UPDATE = 2;       // See 'Update' below.
     MESSAGE = 3;      // See 'Message' below.
@@ -175,7 +185,8 @@ message Event {
   // Type of the call, indicates which optional field below should be
   // present if that type has a nested message definition.
   // In case type is SUBSCRIBED, no message needs to be set.
-  required Type type = 3;
+  // See comments on `Event::Type` above on the reasoning behind this field being optional.
+  optional Type type = 3;
 
   optional Subscribe subscribe = 4;
   optional Update update = 5;

http://git-wip-us.apache.org/repos/asf/mesos/blob/40fd5672/include/mesos/v1/executor/executor.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/executor/executor.proto b/include/mesos/v1/executor/executor.proto
index d7b1dd5..4552fb5 100644
--- a/include/mesos/v1/executor/executor.proto
+++ b/include/mesos/v1/executor/executor.proto
@@ -32,6 +32,12 @@ message Event {
   // Possible event types, followed by message definitions if
   // applicable.
   enum Type {
+    // This must be the first enum value in this list, to
+    // ensure that if 'type' is not set, the default value
+    // is UNKNOWN. This enables enum values to be added
+    // in a backwards-compatible way. See: MESOS-4997.
+    UNKNOWN = 0;
+
     SUBSCRIBED = 1;   // See 'Subscribed' below.
     LAUNCH = 2;       // See 'Launch' below.
     KILL = 3;         // See 'Kill' below.
@@ -113,7 +119,8 @@ message Event {
 
   // Type of the event, indicates which optional field below should be
   // present if that type has a nested message definition.
-  required Type type = 1;
+  // Enum fields should be optional, see: MESOS-4997.
+  optional Type type = 1;
 
   optional Subscribed subscribed = 2;
   optional Acknowledged acknowledged = 3;
@@ -134,6 +141,9 @@ message Event {
   // Possible call types, followed by message definitions if
   // applicable.
   enum Type {
+    // See comments above on `Event::Type` for more details on this enum value.
+    UNKNOWN = 0;
+
     SUBSCRIBE = 1;    // See 'Subscribe' below.
     UPDATE = 2;       // See 'Update' below.
     MESSAGE = 3;      // See 'Message' below.
@@ -175,7 +185,8 @@ message Event {
   // Type of the call, indicates which optional field below should be
   // present if that type has a nested message definition.
   // In case type is SUBSCRIBED, no message needs to be set.
-  required Type type = 3;
+  // See comments on `Event::Type` above on the reasoning behind this field being optional.
+  optional Type type = 3;
 
   optional Subscribe subscribe = 4;
   optional Update update = 5;

http://git-wip-us.apache.org/repos/asf/mesos/blob/40fd5672/src/examples/test_http_executor.cpp
----------------------------------------------------------------------
diff --git a/src/examples/test_http_executor.cpp b/src/examples/test_http_executor.cpp
index 562b0ac..ceb489d 100644
--- a/src/examples/test_http_executor.cpp
+++ b/src/examples/test_http_executor.cpp
@@ -188,6 +188,10 @@ public:
           cout << "Received an ERROR event" << endl;
           break;
         }
+
+        default: {
+          UNREACHABLE();
+        }
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/40fd5672/src/slave/validation.cpp
----------------------------------------------------------------------
diff --git a/src/slave/validation.cpp b/src/slave/validation.cpp
index bc8d671..ec1a4b6 100644
--- a/src/slave/validation.cpp
+++ b/src/slave/validation.cpp
@@ -29,6 +29,10 @@ Option<Error> validate(const mesos::executor::Call& call)
     return Error("Not initialized: " + call.InitializationErrorString());
   }
 
+  if (!call.has_type()) {
+    return Error("Expecting 'type' to be present");
+  }
+
   // All calls should have executor id set.
   if (!call.has_executor_id()) {
     return Error("Expecting 'executor_id' to be present");

http://git-wip-us.apache.org/repos/asf/mesos/blob/40fd5672/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 2369488..dc0e4dd 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -1055,6 +1055,8 @@ public:
       case Event::ERROR:
         error(mesos, event.error());
         break;
+      default:
+        UNREACHABLE();
     }
   }
 };