[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mesos-commits
Subject:    mesos git commit: Take possible isNone() into account when comparing two Option<double> CPU resource
From:       bernd () apache ! org
Date:       2015-11-27 15:45:50
Message-ID: 07f0e8c37b6844fdb024e5ee508ba1ad () git ! apache ! org
[Download RAW message or body]

Repository: mesos
Updated Branches:
  refs/heads/master bd0c61cef -> 695bff500


Take possible isNone() into account when comparing two Option<double>
CPU resource numbers.

Addendum to https://reviews.apache.org/r/40730.

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


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

Branch: refs/heads/master
Commit: 695bff500fc964bf26059f96239d2fc78239b085
Parents: bd0c61c
Author: Bernd Mathiske <bernd@mesosphere.io>
Authored: Fri Nov 27 16:45:07 2015 +0100
Committer: Bernd Mathiske <bernd@mesosphere.io>
Committed: Fri Nov 27 16:45:07 2015 +0100

----------------------------------------------------------------------
 src/common/resources.cpp | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/695bff50/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 5cf04ea..98804a4 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -32,8 +32,12 @@
 #include <stout/lambda.hpp>
 #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 +45,7 @@ using std::string;
 using std::vector;
 
 using google::protobuf::RepeatedPtrField;
+
 using mesos::internal::master::MIN_CPUS;
 
 
@@ -939,14 +944,24 @@ 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.mem() == mem() &&
         result.disk() == disk() &&
         result.ports() == ports());
-  CHECK_NEAR(result.cpus().get(), cpus().get(), MIN_CPUS);
+
+  // 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().isNone() ? 0.0 : result.cpus().get(),
+             cpus().isNone()? 0.0 : cpus().get(),
+             MIN_CPUS);
 
   return result;
 }

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic