You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2018/05/31 00:32:47 UTC

[1/2] mesos git commit: Rejected non-zero scalar resource values which be represented as zero.

Repository: mesos
Updated Branches:
  refs/heads/1.4.x c02eccc8f -> 5e24f269b


Rejected non-zero scalar resource values which be represented as zero.

Internally values of scalar resources are stored in a fixed point
representation. This can lead to (expected) precision loss.

This patch updates the resource validation ensuring that values of
scalar resources are either zero or large enough so that they are
still represented as non-zero values after conversion to the internal
fixed point format. With that we can still parse resources containing
resource values explictly set to zero to be able to distinguish empty
and abset resources, but prevent propagation of values accidentially
rounded to an effectively empty result.

While this patch should not change valid, intended use cases, it might
change the behavior for erroneous, already broken framework workflows.

Review: https://reviews.apache.org/r/67274/
(cherry picked from commit a854a256e5ba8e5639e3f48ad85709eebad21725)


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

Branch: refs/heads/1.4.x
Commit: 1d529ebc3f201cfe46c310e6fec429521e5e7f00
Parents: c02eccc
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Wed May 30 16:45:12 2018 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 30 17:32:37 2018 -0700

----------------------------------------------------------------------
 src/common/resources.cpp      |  7 +++++--
 src/tests/master_tests.cpp    | 11 +++++++----
 src/tests/resources_tests.cpp | 16 +++++++++-------
 3 files changed, 21 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1d529ebc/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index b31e8a7..499cc29 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -783,8 +783,11 @@ Option<Error> Resources::validate(const Resource& resource)
       return Error("Invalid scalar resource");
     }
 
-    if (resource.scalar().value() < 0) {
-      return Error("Invalid scalar resource: value < 0");
+    // We do not allow negative scalar resource values or
+    // non-zero values which would be represented as zero.
+    if (resource.scalar().value() != 0 &&
+        resource.scalar() <= Value::Scalar()) {
+      return Error("Invalid scalar resource: value <= 0");
     }
   } else if (resource.type() == Value::RANGES) {
     if (resource.has_scalar() ||

http://git-wip-us.apache.org/repos/asf/mesos/blob/1d529ebc/src/tests/master_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index 5b93ccc..5164adb 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -7406,10 +7406,13 @@ TEST_F(MasterTest, TaskWithTinyResources)
 
   Offer offer = offers.get()[0];
 
-  TaskInfo task = createTask(
-      offer.slave_id(),
-      Resources::parse("cpus:0.00001;mem:1").get(),
-      SLEEP_COMMAND(1000));
+  // We manually construct the CPU resources since the parser constructing
+  // `Resources` instead of `Resource` already performs validation and would
+  // reject the input.
+  Resources resources = Resources::parse("mem:1").get();
+  resources += Resources::parse("cpus", "0.00001", "*").get();
+
+  TaskInfo task = createTask(offer.slave_id(), resources, SLEEP_COMMAND(1000));
 
   Future<TaskStatus> runningStatus;
   EXPECT_CALL(sched, statusUpdate(&driver, _))

http://git-wip-us.apache.org/repos/asf/mesos/blob/1d529ebc/src/tests/resources_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/resources_tests.cpp b/src/tests/resources_tests.cpp
index 8a86efe..5e08c3a 100644
--- a/src/tests/resources_tests.cpp
+++ b/src/tests/resources_tests.cpp
@@ -1925,16 +1925,18 @@ TEST(ResourcesTest, PrecisionRounding)
 }
 
 
-TEST(ResourcesTest, PrecisionVerySmallValue)
+TEST(ResourcesTest, VerySmallValue)
 {
-  Resources r1 = Resources::parse("cpus:2;mem:1024").get();
-  Resources r2 = Resources::parse("cpus:0.00001;mem:1").get();
+  Try<Resources> resources = Resources::parse("cpus:0.00001");
+  EXPECT_ERROR(resources);
+}
 
-  Resources r3 = r1 - (r1 - r2);
-  EXPECT_TRUE(r3.contains(r2));
 
-  Resources r4 = Resources::parse("cpus:0;mem:1").get();
-  EXPECT_EQ(r2, r4);
+TEST(ResourcesTest, AbsentResources)
+{
+  Try<Resources> resources = Resources::parse("gpus:0");
+  ASSERT_SOME(resources);
+  EXPECT_EQ(0, resources->size());
 }
 
 


[2/2] mesos git commit: Added MESOS-8945 to 1.4.2 CHANGELOG.

Posted by ji...@apache.org.
Added MESOS-8945 to 1.4.2 CHANGELOG.

(cherry picked from commit 3a3b4124e182984b2f26842414f77eeb30ca9087)


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

Branch: refs/heads/1.4.x
Commit: 5e24f269be57f81f3237b2bc5c5495ce994828b7
Parents: 1d529eb
Author: Jie Yu <yu...@gmail.com>
Authored: Wed May 30 17:30:43 2018 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed May 30 17:32:38 2018 -0700

----------------------------------------------------------------------
 CHANGELOG | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5e24f269/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index cdd7622..f67fe40 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -34,6 +34,7 @@ Release Notes - Mesos - Version 1.4.2 (WIP)
   * [MESOS-8881] - Enable epoll backend in libevent integration.
   * [MESOS-8885] - Disable libevent debug mode.
   * [MESOS-8904] - Master crash when removing quota.
+  * [MESOS-8945] - Master check failure due to CHECK_SOME(providerId).
   * [MESOS-8947] - Improve the container preparing logging in IOSwitchboard and volume/secret isolator.
   * [MESOS-8952] - process::await/collect n^2 performance issue.
   * [MESOS-8963] - Executor crash trying to print container ID.