You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gr...@apache.org on 2018/07/02 19:45:54 UTC

[3/5] mesos git commit: Fixed a bug in `createStrippedScalarQuantity()`.

Fixed a bug in `createStrippedScalarQuantity()`.

This patch fixes `createStrippedScalarQuantity()` by
stripping the revocable field in resources.

Also added a test.

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


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

Branch: refs/heads/1.5.x
Commit: 7a19d085c8aead7693c5d6212dbba7db771e60f6
Parents: c9efa40
Author: Meng Zhu <mz...@mesosphere.io>
Authored: Wed Jun 20 16:59:54 2018 -0700
Committer: Greg Mann <gr...@gmail.com>
Committed: Mon Jul 2 12:21:40 2018 -0700

----------------------------------------------------------------------
 src/common/resources.cpp      |  1 +
 src/tests/resources_tests.cpp | 13 +++++++++++++
 src/v1/resources.cpp          |  1 +
 3 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7a19d085/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 6b2084b..76e14e8 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -1633,6 +1633,7 @@ Resources Resources::createStrippedScalarQuantity() const
 
       scalar.clear_disk();
       scalar.clear_shared();
+      scalar.clear_revocable();
       stripped.add(scalar);
     }
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/7a19d085/src/tests/resources_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/resources_tests.cpp b/src/tests/resources_tests.cpp
index 0b25e42..30144a9 100644
--- a/src/tests/resources_tests.cpp
+++ b/src/tests/resources_tests.cpp
@@ -2683,6 +2683,19 @@ TEST(ResourcesOperationTest, StrippedResourcesNonScalar)
 }
 
 
+TEST(ResourceOperationTest, StrippedResourcesRevocable)
+{
+  Resource plain = Resources::parse("cpus", "1", "*").get();
+
+  Resource revocable = plain;
+  revocable.mutable_revocable();
+
+  Resources stripped = Resources(revocable).createStrippedScalarQuantity();
+
+  EXPECT_EQ(Resources(plain), stripped);
+}
+
+
 TEST(ResourcesOperationTest, CreatePersistentVolumeFromMount)
 {
   Resource::DiskInfo::Source source = createDiskSourceMount("mnt");

http://git-wip-us.apache.org/repos/asf/mesos/blob/7a19d085/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index 06e310f..5ebdc9a 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -1652,6 +1652,7 @@ Resources Resources::createStrippedScalarQuantity() const
 
       scalar.clear_disk();
       scalar.clear_shared();
+      scalar.clear_revocable();
       stripped.add(scalar);
     }
   }