You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2017/02/24 22:42:54 UTC
[1/3] mesos git commit: Added allocation role validation for Reserve
operation.
Repository: mesos
Updated Branches:
refs/heads/master c2bdc651a -> eaec82802
Added allocation role validation for Reserve operation.
With support for multi-role frameworks, we need to make sure that
individual reserve operation cannot mix allocation roles.
Review: https://reviews.apache.org/r/57031/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1d57ce2c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1d57ce2c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1d57ce2c
Branch: refs/heads/master
Commit: 1d57ce2c55332be92fc60ceba1a03d9d452a1d21
Parents: c2bdc65
Author: Jay Guo <gu...@gmail.com>
Authored: Fri Feb 24 14:14:38 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Fri Feb 24 14:28:05 2017 -0800
----------------------------------------------------------------------
src/master/validation.cpp | 10 ++++++++++
src/tests/master_validation_tests.cpp | 31 ++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/1d57ce2c/src/master/validation.cpp
----------------------------------------------------------------------
diff --git a/src/master/validation.cpp b/src/master/validation.cpp
index ac91057..50290bf 100644
--- a/src/master/validation.cpp
+++ b/src/master/validation.cpp
@@ -1742,6 +1742,16 @@ Option<Error> validate(
}
}
+ if (frameworkInfo.isSome()) {
+ // If the operation is being applied by a framework, we also
+ // ensure that across all the resources, they are allocated
+ // to a single role.
+ error = resource::validateAllocatedToSingleRole(reserve.resources());
+ if (error.isSome()) {
+ return Error("Invalid reservation resources: " + error->message);
+ }
+ }
+
return None();
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/1d57ce2c/src/tests/master_validation_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_validation_tests.cpp b/src/tests/master_validation_tests.cpp
index 9c4ad4f..c455c06 100644
--- a/src/tests/master_validation_tests.cpp
+++ b/src/tests/master_validation_tests.cpp
@@ -538,6 +538,37 @@ TEST_F(ReserveOperationValidationTest, UnexpectedAllocatedResource)
}
+TEST_F(ReserveOperationValidationTest, MixedAllocationRoles)
+{
+ Resource resource1 = Resources::parse("cpus", "8", "role1").get();
+ resource1.mutable_reservation()->CopyFrom(createReservationInfo("principal"));
+ Resource resource2 = Resources::parse("mem", "8", "role2").get();
+ resource2.mutable_reservation()->CopyFrom(createReservationInfo("principal"));
+
+ Offer::Operation::Reserve reserve;
+ reserve.mutable_resources()->CopyFrom(
+ allocatedResources(resource1, "role1") +
+ allocatedResources(resource2, "role2"));
+
+ FrameworkInfo frameworkInfo;
+ frameworkInfo.add_roles("role1");
+ frameworkInfo.add_roles("role2");
+ frameworkInfo.add_capabilities()->set_type(
+ FrameworkInfo::Capability::MULTI_ROLE);
+
+ Option<Error> error =
+ operation::validate(reserve, "principal", frameworkInfo);
+
+ ASSERT_SOME(error);
+ EXPECT_TRUE(
+ strings::contains(
+ error->message,
+ "Invalid reservation resources: The resources have multiple"
+ " allocation roles ('role2' and 'role1') but only one allocation"
+ " role is allowed"));
+}
+
+
class UnreserveOperationValidationTest : public MesosTest {};
[2/3] mesos git commit: Added allocation role validation for Create
operation.
Posted by bm...@apache.org.
Added allocation role validation for Create operation.
With support for multi-role frameworks, we need to make sure that
individual create operation cannot mix allocation roles.
Review: https://reviews.apache.org/r/57032/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/949e78f2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/949e78f2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/949e78f2
Branch: refs/heads/master
Commit: 949e78f2ead236f4f7e428993b5ebb10d24358a5
Parents: 1d57ce2
Author: Jay Guo <gu...@gmail.com>
Authored: Fri Feb 24 14:20:16 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Fri Feb 24 14:34:30 2017 -0800
----------------------------------------------------------------------
src/master/validation.cpp | 10 ++++++++++
src/tests/master_validation_tests.cpp | 32 ++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/949e78f2/src/master/validation.cpp
----------------------------------------------------------------------
diff --git a/src/master/validation.cpp b/src/master/validation.cpp
index 50290bf..1f2343d 100644
--- a/src/master/validation.cpp
+++ b/src/master/validation.cpp
@@ -1846,6 +1846,16 @@ Option<Error> validate(
}
}
+ if (frameworkInfo.isSome()) {
+ // If the operation is being applied by a framework, we also
+ // ensure that across all the resources, they are allocated
+ // to a single role.
+ error = resource::validateAllocatedToSingleRole(create.volumes());
+ if (error.isSome()) {
+ return Error("Invalid volume resources: " + error->message);
+ }
+ }
+
return None();
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/949e78f2/src/tests/master_validation_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_validation_tests.cpp b/src/tests/master_validation_tests.cpp
index c455c06..5a84c8d 100644
--- a/src/tests/master_validation_tests.cpp
+++ b/src/tests/master_validation_tests.cpp
@@ -746,6 +746,7 @@ TEST_F(CreateOperationValidationTest, SharedVolumeBasedOnCapability)
{
Resource volume = createDiskResource(
"128", "role1", "1", "path1", None(), true); // Shared.
+ volume.mutable_allocation_info()->set_role("role1");
Offer::Operation::Create create;
create.add_volumes()->CopyFrom(volume);
@@ -862,6 +863,37 @@ TEST_F(CreateOperationValidationTest, InsufficientDiskResource)
}
+TEST_F(CreateOperationValidationTest, MixedAllocationRole)
+{
+ Resource volume1 = Resources::parse("disk", "128", "role1").get();
+ volume1.mutable_disk()->CopyFrom(createDiskInfo("id1", "path1"));
+ Resource volume2 = Resources::parse("disk", "256", "role2").get();
+ volume2.mutable_disk()->CopyFrom(createDiskInfo("id2", "path2"));
+
+ Offer::Operation::Create create;
+ create.mutable_volumes()->CopyFrom(
+ allocatedResources(volume1, "role1") +
+ allocatedResources(volume2, "role2"));
+
+ FrameworkInfo frameworkInfo;
+ frameworkInfo.add_roles("role1");
+ frameworkInfo.add_roles("role2");
+ frameworkInfo.add_capabilities()->set_type(
+ FrameworkInfo::Capability::MULTI_ROLE);
+
+ Option<Error> error = operation::validate(
+ create, Resources(), None(), frameworkInfo);
+
+ ASSERT_SOME(error);
+ EXPECT_TRUE(
+ strings::contains(
+ error->message,
+ "Invalid volume resources: The resources have multiple allocation"
+ " roles ('role2' and 'role1') but only one allocation role is"
+ " allowed"));
+}
+
+
class DestroyOperationValidationTest : public ::testing::Test {};
[3/3] mesos git commit: Cleaned up an error message formatting.
Posted by bm...@apache.org.
Cleaned up an error message formatting.
This places the open and closing quotes on the same line.
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/eaec8280
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/eaec8280
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/eaec8280
Branch: refs/heads/master
Commit: eaec82802429fd43fb7c4c73ace74b2ad9c249e0
Parents: 949e78f
Author: Benjamin Mahler <bm...@apache.org>
Authored: Fri Feb 24 14:22:57 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Fri Feb 24 14:34:33 2017 -0800
----------------------------------------------------------------------
src/master/validation.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/eaec8280/src/master/validation.cpp
----------------------------------------------------------------------
diff --git a/src/master/validation.cpp b/src/master/validation.cpp
index 1f2343d..41ef0d0 100644
--- a/src/master/validation.cpp
+++ b/src/master/validation.cpp
@@ -604,10 +604,9 @@ Option<Error> validateAllocatedToSingleRole(const Resources& resources)
}
if (_role != role.get()) {
- return Error(
- "The resources have multiple allocation roles ('" + _role +
- "' and '" + role.get() + "') but only one allocation role" +
- " is allowed");
+ return Error("The resources have multiple allocation roles"
+ " ('" + _role + "' and '" + role.get() + "')"
+ " but only one allocation role is allowed");
}
}