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:10:22 UTC

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

Repository: mesos
Updated Branches:
  refs/heads/master 513a20097 -> f0191b255


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

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

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


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

Branch: refs/heads/master
Commit: f0191b25554918e3aa289da3513ef422edd9372a
Parents: 513a200
Author: Yong Tang <yo...@outlook.com>
Authored: Fri Mar 25 14:09:18 2016 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Mar 25 14:10:04 2016 -0700

----------------------------------------------------------------------
 CHANGELOG                                  |  3 +++
 include/mesos/scheduler/scheduler.proto    | 15 +++++++++++++--
 include/mesos/v1/scheduler/scheduler.proto | 15 +++++++++++++--
 src/master/validation.cpp                  |  4 ++++
 src/tests/mesos.hpp                        |  2 ++
 5 files changed, 35 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f0191b25/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index fef0cbf..cd551d8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -32,6 +32,9 @@ Additional API Changes:
   * [MESOS-4735] - Add 'filename' field to CommandInfo.URI in Scheduler API
     and v1 Scheduler HTTP API.
 
+  * [MESOS-5014] - Changes Call and Event Type enums in scheduler.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/f0191b25/include/mesos/scheduler/scheduler.proto
----------------------------------------------------------------------
diff --git a/include/mesos/scheduler/scheduler.proto b/include/mesos/scheduler/scheduler.proto
index 0049e13..078c655 100644
--- a/include/mesos/scheduler/scheduler.proto
+++ b/include/mesos/scheduler/scheduler.proto
@@ -33,6 +33,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.
     OFFERS = 2;     // See 'Offers' below.
     RESCIND = 3;    // See 'Rescind' below.
@@ -133,7 +139,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 Offers offers = 3;
@@ -155,6 +162,9 @@ message Call {
   // 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.
     TEARDOWN = 2;    // Shuts down all tasks/executors and removes framework.
     ACCEPT = 3;      // See 'Accept' below.
@@ -312,7 +322,8 @@ message Call {
 
   // Type of the call, indicates which optional field below should be
   // present if that type has a nested message definition.
-  required Type type = 2;
+  // See comments on `Event::Type` above on the reasoning behind this field being optional.
+  optional Type type = 2;
 
   optional Subscribe subscribe = 3;
   optional Accept accept = 4;

http://git-wip-us.apache.org/repos/asf/mesos/blob/f0191b25/include/mesos/v1/scheduler/scheduler.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/scheduler/scheduler.proto b/include/mesos/v1/scheduler/scheduler.proto
index 09fafed..8ed9e19 100644
--- a/include/mesos/v1/scheduler/scheduler.proto
+++ b/include/mesos/v1/scheduler/scheduler.proto
@@ -33,6 +33,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.
     OFFERS = 2;     // See 'Offers' below.
     RESCIND = 3;    // See 'Rescind' below.
@@ -133,7 +139,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 Offers offers = 3;
@@ -155,6 +162,9 @@ message Call {
   // 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.
     TEARDOWN = 2;    // Shuts down all tasks/executors and removes framework.
     ACCEPT = 3;      // See 'Accept' below.
@@ -302,7 +312,8 @@ message Call {
 
   // Type of the call, indicates which optional field below should be
   // present if that type has a nested message definition.
-  required Type type = 2;
+  // See comments on `Event::Type` above on the reasoning behind this field being optional.
+  optional Type type = 2;
 
   optional Subscribe subscribe = 3;
   optional Accept accept = 4;

http://git-wip-us.apache.org/repos/asf/mesos/blob/f0191b25/src/master/validation.cpp
----------------------------------------------------------------------
diff --git a/src/master/validation.cpp b/src/master/validation.cpp
index 701a5c4..9c9e422 100644
--- a/src/master/validation.cpp
+++ b/src/master/validation.cpp
@@ -59,6 +59,10 @@ Option<Error> validate(const mesos::scheduler::Call& call)
     return Error("Not initialized: " + call.InitializationErrorString());
   }
 
+  if (!call.has_type()) {
+    return Error("Expecting 'type' to be present");
+  }
+
   if (call.type() == mesos::scheduler::Call::SUBSCRIBE) {
     if (!call.has_subscribe()) {
       return Error("Expecting 'subscribe' to be present");

http://git-wip-us.apache.org/repos/asf/mesos/blob/f0191b25/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index aaef158..2369488 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -930,6 +930,8 @@ public:
       case Event::HEARTBEAT:
         heartbeat(mesos);
         break;
+      default:
+        UNREACHABLE();
     }
   }
 };