You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2015/12/18 11:28:14 UTC

mesos git commit: Ported approx. Option CPU resource number comparison to v1.

Repository: mesos
Updated Branches:
  refs/heads/master f9f379ddc -> 7a57b0c6c


Ported approx. Option<double> CPU resource number comparison to v1.

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


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

Branch: refs/heads/master
Commit: 7a57b0c6c403d3c5dd6b67087f8727d1b348b625
Parents: f9f379d
Author: Bernd Mathiske <be...@mesosphere.io>
Authored: Fri Dec 18 10:59:52 2015 +0100
Committer: Bernd Mathiske <be...@mesosphere.io>
Committed: Fri Dec 18 10:59:52 2015 +0100

----------------------------------------------------------------------
 src/common/resources.cpp |  4 +---
 src/v1/resources.cpp     | 21 ++++++++++++++++++---
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7a57b0c6/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 5a79817..b9d31ae 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -962,9 +962,7 @@ Try<Resources> Resources::apply(const Offer::Operation& operation) const
   // operations such as unparsing and then parsing a floating point number.
   // TODO(bernd-mesos): Of course, they might also accumulate, so we need a
   // better long-term fix. Apply one here when solving MESOS-3997.
-  CHECK_NEAR(result.cpus().isNone() ? 0.0 : result.cpus().get(),
-             cpus().isNone()? 0.0 : cpus().get(),
-             MIN_CPUS);
+  CHECK_NEAR(result.cpus().getOrElse(0.0), cpus().getOrElse(0.0), MIN_CPUS);
 
   return result;
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/7a57b0c6/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index d300842..0c0eee6 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -33,6 +33,11 @@
 #include <stout/protobuf.hpp>
 #include <stout/strings.hpp>
 
+// TODO(bernd-mesos): Remove this interim dependency in the course of
+// solving MESOS-3997.
+#include <master/constants.hpp>
+
+
 using std::map;
 using std::ostream;
 using std::set;
@@ -41,6 +46,8 @@ using std::vector;
 
 using google::protobuf::RepeatedPtrField;
 
+using mesos::internal::master::MIN_CPUS;
+
 
 namespace mesos {
 namespace v1 {
@@ -942,15 +949,23 @@ Try<Resources> Resources::apply(const Offer::Operation& operation) const
       return Error("Unknown offer operation " + stringify(operation.type()));
   }
 
-  // This is a sanity check to ensure the amount of each type of
+  // The following are sanity checks to ensure the amount of each type of
   // resource does not change.
   // TODO(jieyu): Currently, we only check known resource types like
   // cpus, mem, disk, ports, etc. We should generalize this.
-  CHECK(result.cpus() == cpus() &&
-        result.mem() == mem() &&
+
+  CHECK(result.mem() == mem() &&
         result.disk() == disk() &&
         result.ports() == ports());
 
+  // This comparison is an interim fix - see MESOS-3552. We are making it
+  // reasonably certain that almost equal values are correctly regarded as
+  // equal. Small, usually acceptable, differences occur due to numeric
+  // operations such as unparsing and then parsing a floating point number.
+  // TODO(bernd-mesos): Of course, they might also accumulate, so we need a
+  // better long-term fix. Apply one here when solving MESOS-3997.
+  CHECK_NEAR(result.cpus().getOrElse(0.0), cpus().getOrElse(0.0), MIN_CPUS);
+
   return result;
 }