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/08/15 22:25:28 UTC

[2/4] mesos git commit: Made `Offer::Operation::Type` optional with default `UNKNOWN`.

Made `Offer::Operation::Type` optional with default `UNKNOWN`.

This is necessary to introduce new offer operations in a backwards
compatible manner. See MESOS-4997 for context.

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


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

Branch: refs/heads/master
Commit: d3adee2d9500a0e1ed5124df7c79f8043ec2bfda
Parents: c7f5d87
Author: Vinod Kone <vi...@gmail.com>
Authored: Fri Aug 12 14:02:19 2016 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Mon Aug 15 15:25:05 2016 -0700

----------------------------------------------------------------------
 include/mesos/mesos.proto    |  3 ++-
 include/mesos/v1/mesos.proto |  3 ++-
 src/common/resources.cpp     |  4 ++--
 src/master/master.cpp        | 11 +++++++++--
 src/v1/resources.cpp         |  4 ++--
 5 files changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d3adee2d/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 90518a2..0326a5c 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -1252,6 +1252,7 @@ message Offer {
   // Defines an operation that can be performed against offers.
   message Operation {
     enum Type {
+      UNKNOWN = 0;
       LAUNCH = 1;
       RESERVE = 2;
       UNRESERVE = 3;
@@ -1279,7 +1280,7 @@ message Offer {
       repeated Resource volumes = 1;
     }
 
-    required Type type = 1;
+    optional Type type = 1;
     optional Launch launch = 2;
     optional Reserve reserve = 3;
     optional Unreserve unreserve = 4;

http://git-wip-us.apache.org/repos/asf/mesos/blob/d3adee2d/include/mesos/v1/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index 93a4bce..fa29335 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -1251,6 +1251,7 @@ message Offer {
   // Defines an operation that can be performed against offers.
   message Operation {
     enum Type {
+      UNKNOWN = 0;
       LAUNCH = 1;
       RESERVE = 2;
       UNRESERVE = 3;
@@ -1278,7 +1279,7 @@ message Offer {
       repeated Resource volumes = 1;
     }
 
-    required Type type = 1;
+    optional Type type = 1;
     optional Launch launch = 2;
     optional Reserve reserve = 3;
     optional Unreserve unreserve = 4;

http://git-wip-us.apache.org/repos/asf/mesos/blob/d3adee2d/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 6b7af91..f180a0f 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -1234,8 +1234,8 @@ Try<Resources> Resources::apply(const Offer::Operation& operation) const
       break;
     }
 
-    default:
-      return Error("Unknown offer operation " + stringify(operation.type()));
+    case Offer::Operation::UNKNOWN:
+      return Error("Unknown offer operation");
   }
 
   // The following are sanity checks to ensure the amount of each type of

http://git-wip-us.apache.org/repos/asf/mesos/blob/d3adee2d/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 0bd1a34..33c2ba1 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -3426,6 +3426,12 @@ void Master::accept(
 
         break;
       }
+
+      case Offer::Operation::UNKNOWN: {
+        // TODO(vinod): Send an error event to the scheduler?
+        LOG(ERROR) << "Ignoring unknown offer operation";
+        break;
+      }
     }
   }
 
@@ -3861,9 +3867,10 @@ void Master::_accept(
         break;
       }
 
-      default:
-        LOG(ERROR) << "Unsupported offer operation " << operation.type();
+      case Offer::Operation::UNKNOWN: {
+        LOG(ERROR) << "Ignoring unknown offer operation";
         break;
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/d3adee2d/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index 03ee0cb..4948b21 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -1237,8 +1237,8 @@ Try<Resources> Resources::apply(const Offer::Operation& operation) const
       break;
     }
 
-    default:
-      return Error("Unknown offer operation " + stringify(operation.type()));
+    case Offer::Operation::UNKNOWN:
+      return Error("Unknown offer operation");
   }
 
   // The following are sanity checks to ensure the amount of each type of