Maintenance Primitives: Added unavailability to Allocator Slave struct. Review: https://reviews.apache.org/r/37173
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ea48105a Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ea48105a Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ea48105a Branch: refs/heads/master Commit: ea48105aa68f249dd409c60ed1dd4998f3498e1e Parents: ee1eb2b Author: Joris Van Remoortere <[email protected]> Authored: Sun Aug 30 14:04:47 2015 -0400 Committer: Joris Van Remoortere <[email protected]> Committed: Mon Sep 14 13:58:37 2015 -0400 ---------------------------------------------------------------------- include/mesos/master/allocator.hpp | 1 + include/mesos/master/allocator.proto | 29 +++++++++++ src/master/allocator/mesos/allocator.hpp | 4 ++ src/master/allocator/mesos/hierarchical.hpp | 44 +++++++++++++++++ src/master/master.cpp | 9 ++++ src/tests/hierarchical_allocator_tests.cpp | 61 +++++++++++++----------- src/tests/master_allocator_tests.cpp | 32 ++++++------- src/tests/mesos.hpp | 9 ++-- src/tests/reservation_endpoints_tests.cpp | 20 ++++---- src/tests/reservation_tests.cpp | 4 +- src/tests/slave_recovery_tests.cpp | 2 +- 11 files changed, 154 insertions(+), 61 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/ea48105a/include/mesos/master/allocator.hpp ---------------------------------------------------------------------- diff --git a/include/mesos/master/allocator.hpp b/include/mesos/master/allocator.hpp index 659f37b..257d2f6 100644 --- a/include/mesos/master/allocator.hpp +++ b/include/mesos/master/allocator.hpp @@ -96,6 +96,7 @@ public: virtual void addSlave( const SlaveID& slaveId, const SlaveInfo& slaveInfo, + const Option<Unavailability>& unavailability, const Resources& total, const hashmap<FrameworkID, Resources>& used) = 0; http://git-wip-us.apache.org/repos/asf/mesos/blob/ea48105a/include/mesos/master/allocator.proto ---------------------------------------------------------------------- diff --git a/include/mesos/master/allocator.proto b/include/mesos/master/allocator.proto index 10fd9a2..b42f19d 100644 --- a/include/mesos/master/allocator.proto +++ b/include/mesos/master/allocator.proto @@ -28,3 +28,32 @@ message RoleInfo { required string name = 1; optional double weight = 2 [default = 1]; } + + +/** + * Describes the status of an inverse offer. + * + * This is a protobuf so as to be able to share the status to inverse offers + * through endpoints such as the maintenance status endpoint. + */ +// TODO(jmlvanre): Copy this when V1 Allocator API is introduced. +message InverseOfferStatus { + enum Status { + // We have not received a response yet. This is the default state before + // receiving a response. + UNKNOWN = 1; + // The framework is ok with the inverse offer. This means it will not + // violate any SLAs and will attempt to evacuate any tasks running on the + // agent. If the tasks are not evacuated by the framework, the operator can + // manually shut down the slave knowing that the framework will not have + // violated its SLAs. + ACCEPT = 2; + // The framework wants to block the maintenance operation from happening. An + // example would be that it can not meet its SLA by losing resources. + DECLINE = 3; + } + + required Status status = 1; + + // TODO(jmlvanre): Capture decline message. +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mesos/blob/ea48105a/src/master/allocator/mesos/allocator.hpp ---------------------------------------------------------------------- diff --git a/src/master/allocator/mesos/allocator.hpp b/src/master/allocator/mesos/allocator.hpp index aa55755..c845723 100644 --- a/src/master/allocator/mesos/allocator.hpp +++ b/src/master/allocator/mesos/allocator.hpp @@ -75,6 +75,7 @@ public: void addSlave( const SlaveID& slaveId, const SlaveInfo& slaveInfo, + const Option<Unavailability>& unavailability, const Resources& total, const hashmap<FrameworkID, Resources>& used); @@ -165,6 +166,7 @@ public: virtual void addSlave( const SlaveID& slaveId, const SlaveInfo& slaveInfo, + const Option<Unavailability>& unavailability, const Resources& total, const hashmap<FrameworkID, Resources>& used) = 0; @@ -316,6 +318,7 @@ template <typename AllocatorProcess> inline void MesosAllocator<AllocatorProcess>::addSlave( const SlaveID& slaveId, const SlaveInfo& slaveInfo, + const Option<Unavailability>& unavailability, const Resources& total, const hashmap<FrameworkID, Resources>& used) { @@ -324,6 +327,7 @@ inline void MesosAllocator<AllocatorProcess>::addSlave( &MesosAllocatorProcess::addSlave, slaveId, slaveInfo, + unavailability, total, used); } http://git-wip-us.apache.org/repos/asf/mesos/blob/ea48105a/src/master/allocator/mesos/hierarchical.hpp ---------------------------------------------------------------------- diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp index fbf353d..f86a701 100644 --- a/src/master/allocator/mesos/hierarchical.hpp +++ b/src/master/allocator/mesos/hierarchical.hpp @@ -36,6 +36,7 @@ #include <stout/check.hpp> #include <stout/duration.hpp> #include <stout/hashmap.hpp> +#include <stout/hashset.hpp> #include <stout/stopwatch.hpp> #include <stout/stringify.hpp> @@ -112,6 +113,7 @@ public: void addSlave( const SlaveID& slaveId, const SlaveInfo& slaveInfo, + const Option<Unavailability>& unavailability, const Resources& total, const hashmap<FrameworkID, Resources>& used); @@ -258,6 +260,40 @@ protected: bool checkpoint; // Whether slave supports checkpointing. std::string hostname; + + // Represents a scheduled unavailability due to maintenance for a specific + // slave, and the responses from frameworks as to whether they will be able + // to gracefully handle this unavailability. + // NOTE: We currently implement maintenance in the allocator to be able to + // leverage state and features such as the FrameworkSorter and Filters. + struct Maintenance + { + Maintenance(const Unavailability& _unavailability) + : unavailability(_unavailability) {} + + // The start time and optional duration of the event. + Unavailability unavailability; + + // A mapping of frameworks to the inverse offer status associated with + // this unavailability. + // NOTE: We currently lose this information during a master fail over + // since it is not persisted or replicated. This is ok as the new master's + // allocator will send out new inverse offers and re-collect the + // information. This is similar to all the outstanding offers from an old + // master being invalidated, and new offers being sent out. + hashmap<FrameworkID, mesos::master::InverseOfferStatus> statuses; + + // Represent the "unit of accounting" for maintenance. When a + // `FrameworkID` is present in the hashset it means an inverse offer has + // been sent out. When it is not present it means no offer is currently + // outstanding. + hashset<FrameworkID> offersOutstanding; + }; + + // When the `maintenance` is set the slave is scheduled to be unavailable at + // a given point in time, for an optional duration. This information is used + // to send out `InverseOffers`. + Option<Maintenance> maintenance; }; hashmap<SlaveID, Slave> slaves; @@ -509,6 +545,7 @@ void HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::addSlave( const SlaveID& slaveId, const SlaveInfo& slaveInfo, + const Option<Unavailability>& unavailability, const Resources& total, const hashmap<FrameworkID, Resources>& used) { @@ -540,6 +577,13 @@ HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::addSlave( slaves[slaveId].checkpoint = slaveInfo.checkpoint(); slaves[slaveId].hostname = slaveInfo.hostname(); + // NOTE: We currently implement maintenance in the allocator to be able to + // leverage state and features such as the FrameworkSorter and Filters. + if (unavailability.isSome()) { + slaves[slaveId].maintenance = + typename Slave::Maintenance(unavailability.get()); + } + LOG(INFO) << "Added slave " << slaveId << " (" << slaves[slaveId].hostname << ") with " << slaves[slaveId].total << " (allocated: " << slaves[slaveId].allocated << ")"; http://git-wip-us.apache.org/repos/asf/mesos/blob/ea48105a/src/master/master.cpp ---------------------------------------------------------------------- diff --git a/src/master/master.cpp b/src/master/master.cpp index 5c2f032..1bed6a6 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -5445,9 +5445,18 @@ void Master::addSlave( } } + CHECK(machines.contains(slave->machineId)); + + // Only set unavailability if the protobuf has one set. + Option<Unavailability> unavailability = None(); + if (machines[slave->machineId].info.has_unavailability()) { + unavailability = machines[slave->machineId].info.unavailability(); + } + allocator->addSlave( slave->id, slave->info, + unavailability, slave->totalResources, slave->usedResources); } http://git-wip-us.apache.org/repos/asf/mesos/blob/ea48105a/src/tests/hierarchical_allocator_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp index 9748ca0..0a24b6b 100644 --- a/src/tests/hierarchical_allocator_tests.cpp +++ b/src/tests/hierarchical_allocator_tests.cpp @@ -216,7 +216,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // Total cluster resources will become cpus=2, mem=1024. SlaveInfo slave1 = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(slave1.id(), slave1, slave1.resources(), EMPTY); + allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), EMPTY); // framework1 will be offered all of slave1's resources since it is // the only framework running so far. @@ -242,7 +242,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // role2 share = 0 // framework2 share = 0 SlaveInfo slave2 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addSlave(slave2.id(), slave2, slave2.resources(), EMPTY); + allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), EMPTY); // framework2 will be offered all of slave2's resources since role2 // has the lowest user share, and framework2 is its only framework. @@ -262,7 +262,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // role2 share = 0.16 (cpus=1, mem=512) // framework2 share = 1 SlaveInfo slave3 = createSlaveInfo("cpus:3;mem:2048;disk:0"); - allocator->addSlave(slave3.id(), slave3, slave3.resources(), EMPTY); + allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), EMPTY); // framework2 will be offered all of slave3's resources since role2 // has the lowest share. @@ -287,7 +287,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // role2 share = 0.4 (cpus=4, mem=2560) // framework2 share = 1 SlaveInfo slave4 = createSlaveInfo("cpus:4;mem:4096;disk:0"); - allocator->addSlave(slave4.id(), slave4, slave4.resources(), EMPTY); + allocator->addSlave(slave4.id(), slave4, None(), slave4.resources(), EMPTY); // framework3 will be offered all of slave4's resources since role1 // has the lowest user share, and framework3 has the lowest share of @@ -315,7 +315,7 @@ TEST_F(HierarchicalAllocatorTest, UnreservedDRF) // role2 share = 0.36 (cpus=4, mem=2560) // framework2 share = 1 SlaveInfo slave5 = createSlaveInfo("cpus:1;mem:512;disk:0"); - allocator->addSlave(slave5.id(), slave5, slave5.resources(), EMPTY); + allocator->addSlave(slave5.id(), slave5, None(), slave5.resources(), EMPTY); // Even though framework4 doesn't have any resources, role2 has a // lower share than role1, so framework2 receives slave5's resources. @@ -343,7 +343,7 @@ TEST_F(HierarchicalAllocatorTest, ReservedDRF) SlaveInfo slave1 = createSlaveInfo( "cpus:1;mem:512;disk:0;" "cpus(role1):100;mem(role1):1024;disk(role1):0"); - allocator->addSlave(slave1.id(), slave1, slave1.resources(), EMPTY); + allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), EMPTY); // framework1 will be offered all of the resources. FrameworkInfo framework1 = createFrameworkInfo("role1"); @@ -361,7 +361,7 @@ TEST_F(HierarchicalAllocatorTest, ReservedDRF) // framework2 will be allocated the new resoures. SlaveInfo slave2 = createSlaveInfo("cpus:2;mem:512;disk:0"); - allocator->addSlave(slave2.id(), slave2, slave2.resources(), EMPTY); + allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), EMPTY); allocation = queue.get(); AWAIT_READY(allocation); @@ -373,7 +373,7 @@ TEST_F(HierarchicalAllocatorTest, ReservedDRF) // fairness across roles! We expect framework1 to receive this // slave's resources, since it has fewer unreserved resources. SlaveInfo slave3 = createSlaveInfo("cpus:2;mem:512;disk:0"); - allocator->addSlave(slave3.id(), slave3, slave3.resources(), EMPTY); + allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), EMPTY); allocation = queue.get(); AWAIT_READY(allocation); @@ -390,7 +390,7 @@ TEST_F(HierarchicalAllocatorTest, ReservedDRF) SlaveInfo slave4 = createSlaveInfo( "cpus(role1):2;mem(role1):1024;disk(role1):0"); - allocator->addSlave(slave4.id(), slave4, slave4.resources(), EMPTY); + allocator->addSlave(slave4.id(), slave4, None(), slave4.resources(), EMPTY); allocation = queue.get(); AWAIT_READY(allocation); @@ -413,10 +413,10 @@ TEST_F(HierarchicalAllocatorTest, CoarseGrained) hashmap<FrameworkID, Resources> EMPTY; SlaveInfo slave1 = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(slave1.id(), slave1, slave1.resources(), EMPTY); + allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), EMPTY); SlaveInfo slave2 = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(slave2.id(), slave2, slave2.resources(), EMPTY); + allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), EMPTY); // Once framework1 is added, an allocation will occur. Return the // resources so that we can test what happens when there are 2 @@ -494,7 +494,7 @@ TEST_F(HierarchicalAllocatorTest, SameShareFairness) framework2.id(), framework2, hashmap<SlaveID, Resources>()); SlaveInfo slave = createSlaveInfo("cpus:2;mem:1024;disk:0"); - allocator->addSlave(slave.id(), slave, slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); // Ensure that the slave's resources are alternated between both // frameworks. @@ -534,17 +534,17 @@ TEST_F(HierarchicalAllocatorTest, Reservations) SlaveInfo slave1 = createSlaveInfo( "cpus(role1):2;mem(role1):1024;disk(role1):0"); - allocator->addSlave(slave1.id(), slave1, slave1.resources(), EMPTY); + allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), EMPTY); SlaveInfo slave2 = createSlaveInfo( "cpus(role2):2;mem(role2):1024;cpus:1;mem:1024;disk:0"); - allocator->addSlave(slave2.id(), slave2, slave2.resources(), EMPTY); + allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), EMPTY); // This slave's resources should never be allocated, since there // is no framework for role3. SlaveInfo slave3 = createSlaveInfo( "cpus(role3):1;mem(role3):1024;disk(role3):0"); - allocator->addSlave(slave3.id(), slave3, slave3.resources(), EMPTY); + allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), EMPTY); // framework1 should get all the resources from slave1, and the // unreserved resources from slave2. @@ -588,7 +588,7 @@ TEST_F(HierarchicalAllocatorTest, RecoverResources) SlaveInfo slave = createSlaveInfo( "cpus(role1):1;mem(role1):200;" "cpus:1;mem:200;disk:0"); - allocator->addSlave(slave.id(), slave, slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); // Initially, all the resources are allocated. FrameworkInfo framework1 = createFrameworkInfo("role1"); @@ -660,14 +660,14 @@ TEST_F(HierarchicalAllocatorTest, Allocatable) "cpus:" + stringify(MIN_CPUS / 2) + ";" "mem:" + stringify((MIN_MEM / 2).megabytes()) + ";" "disk:128"); - allocator->addSlave(slave1.id(), slave1, slave1.resources(), EMPTY); + allocator->addSlave(slave1.id(), slave1, None(), slave1.resources(), EMPTY); // Enough cpus to be considered allocatable. SlaveInfo slave2 = createSlaveInfo( "cpus:" + stringify(MIN_CPUS) + ";" "mem:" + stringify((MIN_MEM / 2).megabytes()) + ";" "disk:128"); - allocator->addSlave(slave2.id(), slave2, slave2.resources(), EMPTY); + allocator->addSlave(slave2.id(), slave2, None(), slave2.resources(), EMPTY); Future<Allocation> allocation = queue.get(); AWAIT_READY(allocation); @@ -681,7 +681,7 @@ TEST_F(HierarchicalAllocatorTest, Allocatable) "cpus:" + stringify(MIN_CPUS / 2) + ";" "mem:" + stringify((MIN_MEM).megabytes()) + ";" "disk:128"); - allocator->addSlave(slave3.id(), slave3, slave3.resources(), EMPTY); + allocator->addSlave(slave3.id(), slave3, None(), slave3.resources(), EMPTY); allocation = queue.get(); AWAIT_READY(allocation); @@ -698,7 +698,7 @@ TEST_F(HierarchicalAllocatorTest, Allocatable) "cpus(role1):" + stringify(MIN_CPUS / 1.5) + ";" "mem(role1):" + stringify((MIN_MEM / 2).megabytes()) + ";" "disk:128"); - allocator->addSlave(slave4.id(), slave4, slave4.resources(), EMPTY); + allocator->addSlave(slave4.id(), slave4, None(), slave4.resources(), EMPTY); allocation = queue.get(); AWAIT_READY(allocation); @@ -719,7 +719,7 @@ TEST_F(HierarchicalAllocatorTest, UpdateAllocation) hashmap<FrameworkID, Resources> EMPTY; SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); // Initially, all the resources are allocated. FrameworkInfo framework = createFrameworkInfo("role1"); @@ -791,7 +791,7 @@ TEST_F(HierarchicalAllocatorTest, UpdateAvailableSuccess) hashmap<FrameworkID, Resources> EMPTY; SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); // Construct an offer operation for the framework's allocation. Resources unreserved = Resources::parse("cpus:25;mem:50").get(); @@ -836,7 +836,7 @@ TEST_F(HierarchicalAllocatorTest, UpdateAvailableFail) hashmap<FrameworkID, Resources> EMPTY; SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); // Expect to receive the all of the available resources. FrameworkInfo framework = createFrameworkInfo("role1"); @@ -873,7 +873,7 @@ TEST_F(HierarchicalAllocatorTest, UpdateSlave) hashmap<FrameworkID, Resources> EMPTY; SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); // Add a framework that can accept revocable resources. FrameworkInfo framework = createFrameworkInfo("role1"); @@ -930,7 +930,7 @@ TEST_F(HierarchicalAllocatorTest, OversubscribedNotAllocated) hashmap<FrameworkID, Resources> EMPTY; SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); // Add a framework that does *not* accept revocable resources. FrameworkInfo framework = createFrameworkInfo("role1"); @@ -965,7 +965,7 @@ TEST_F(HierarchicalAllocatorTest, RecoverOversubscribedResources) hashmap<FrameworkID, Resources> EMPTY; SlaveInfo slave = createSlaveInfo("cpus:100;mem:100;disk:100"); - allocator->addSlave(slave.id(), slave, slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); // Add a framework that can accept revocable resources. FrameworkInfo framework = createFrameworkInfo("role1"); @@ -1022,7 +1022,7 @@ TEST_F(HierarchicalAllocatorTest, Whitelist) hashmap<FrameworkID, Resources> EMPTY; SlaveInfo slave = createSlaveInfo("cpus:2;mem:1024"); - allocator->addSlave(slave.id(), slave, slave.resources(), EMPTY); + allocator->addSlave(slave.id(), slave, None(), slave.resources(), EMPTY); FrameworkInfo framework = createFrameworkInfo("*"); allocator->addFramework( @@ -1128,7 +1128,12 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddAndUpdateSlave) "cpus:1;mem:128;disk:1024;" "ports:[31126-31510,31512-31623,31810-31852,31854-31964]").get(); - allocator->addSlave(slaves[i].id(), slaves[i], slaves[i].resources(), used); + allocator->addSlave( + slaves[i].id(), + slaves[i], + None(), + slaves[i].resources(), + used); } // Wait for all the 'addSlave' operations to be processed. http://git-wip-us.apache.org/repos/asf/mesos/blob/ea48105a/src/tests/master_allocator_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/master_allocator_tests.cpp b/src/tests/master_allocator_tests.cpp index 8933196..c6a419b 100644 --- a/src/tests/master_allocator_tests.cpp +++ b/src/tests/master_allocator_tests.cpp @@ -103,7 +103,7 @@ TYPED_TEST(MasterAllocatorTest, SingleFramework) slave::Flags flags = this->CreateSlaveFlags(); flags.resources = Some("cpus:2;mem:1024;disk:0"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave>> slave = this->StartSlave(flags); ASSERT_SOME(slave); @@ -151,7 +151,7 @@ TYPED_TEST(MasterAllocatorTest, ResourcesUnused) slave::Flags flags1 = this->CreateSlaveFlags(); flags1.resources = Some("cpus:2;mem:1024"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave> > slave1 = this->StartSlave(&exec, flags1); ASSERT_SOME(slave1); @@ -254,7 +254,7 @@ TYPED_TEST(MasterAllocatorTest, OutOfOrderDispatch) slave::Flags flags1 = this->CreateSlaveFlags(); flags1.resources = Some("cpus:2;mem:1024"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave> > slave1 = this->StartSlave(flags1); ASSERT_SOME(slave1); @@ -384,7 +384,7 @@ TYPED_TEST(MasterAllocatorTest, SchedulerFailover) slave::Flags flags = this->CreateSlaveFlags(); flags.resources = Some("cpus:3;mem:1024"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave> > slave = this->StartSlave(&exec, flags); ASSERT_SOME(slave); @@ -518,7 +518,7 @@ TYPED_TEST(MasterAllocatorTest, FrameworkExited) slave::Flags flags = this->CreateSlaveFlags(); flags.resources = Some("cpus:3;mem:1024"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave> > slave = this->StartSlave(&containerizer, flags); ASSERT_SOME(slave); @@ -652,7 +652,7 @@ TYPED_TEST(MasterAllocatorTest, SlaveLost) slave::Flags flags1 = this->CreateSlaveFlags(); flags1.resources = Some("cpus:2;mem:1024"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave> > slave1 = this->StartSlave(&exec, flags1); ASSERT_SOME(slave1); @@ -719,7 +719,7 @@ TYPED_TEST(MasterAllocatorTest, SlaveLost) slave::Flags flags2 = this->CreateSlaveFlags(); flags2.resources = string("cpus:3;mem:256;disk:1024;ports:[31000-32000]"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); // Eventually after slave2 is launched, we should get // an offer that contains all of slave2's resources @@ -769,7 +769,7 @@ TYPED_TEST(MasterAllocatorTest, SlaveAdded) slave::Flags flags1 = this->CreateSlaveFlags(); flags1.resources = Some("cpus:3;mem:1024"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave> > slave1 = this->StartSlave(&exec, flags1); ASSERT_SOME(slave1); @@ -818,7 +818,7 @@ TYPED_TEST(MasterAllocatorTest, SlaveAdded) slave::Flags flags2 = this->CreateSlaveFlags(); flags2.resources = Some("cpus:4;mem:2048"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); // After slave2 launches, all of its resources are combined with the // resources on slave1 that the task isn't using. @@ -863,7 +863,7 @@ TYPED_TEST(MasterAllocatorTest, TaskFinished) slave::Flags flags = this->CreateSlaveFlags(); flags.resources = Some("cpus:3;mem:1024"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave> > slave = this->StartSlave(&exec, flags); ASSERT_SOME(slave); @@ -965,7 +965,7 @@ TYPED_TEST(MasterAllocatorTest, CpusOnlyOfferedAndTaskLaunched) slave::Flags flags = this->CreateSlaveFlags(); flags.resources = Some("cpus:2;mem:0"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave> > slave = this->StartSlave(&exec, flags); ASSERT_SOME(slave); @@ -1043,7 +1043,7 @@ TYPED_TEST(MasterAllocatorTest, MemoryOnlyOfferedAndTaskLaunched) slave::Flags flags = this->CreateSlaveFlags(); flags.resources = Some("cpus:0;mem:200"); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave> > slave = this->StartSlave(&exec, flags); ASSERT_SOME(slave); @@ -1260,7 +1260,7 @@ TYPED_TEST(MasterAllocatorTest, FrameworkReregistersFirst) slaveDetector.appoint(master.get()); schedulerDetector.appoint(master.get()); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); slave::Flags flags = this->CreateSlaveFlags(); flags.resources = Some("cpus:2;mem:1024"); @@ -1330,7 +1330,7 @@ TYPED_TEST(MasterAllocatorTest, FrameworkReregistersFirst) AWAIT_READY(addFramework); - EXPECT_CALL(allocator2, addSlave(_, _, _, _)); + EXPECT_CALL(allocator2, addSlave(_, _, _, _, _)); Future<vector<Offer>> resourceOffers2; EXPECT_CALL(sched, resourceOffers(&driver, _)) @@ -1385,7 +1385,7 @@ TYPED_TEST(MasterAllocatorTest, SlaveReregistersFirst) slaveDetector.appoint(master.get()); schedulerDetector.appoint(master.get()); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); slave::Flags flags = this->CreateSlaveFlags(); flags.resources = Some("cpus:2;mem:1024"); @@ -1438,7 +1438,7 @@ TYPED_TEST(MasterAllocatorTest, SlaveReregistersFirst) EXPECT_CALL(allocator2, initialize(_, _, _)); Future<Nothing> addSlave; - EXPECT_CALL(allocator2, addSlave(_, _, _, _)) + EXPECT_CALL(allocator2, addSlave(_, _, _, _, _)) .WillOnce(DoAll(InvokeAddSlave(&allocator2), FutureSatisfy(&addSlave))); http://git-wip-us.apache.org/repos/asf/mesos/blob/ea48105a/src/tests/mesos.hpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index 6b50311..4b65440 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -1301,7 +1301,7 @@ ACTION_P(InvokeUpdateFramework, allocator) ACTION_P(InvokeAddSlave, allocator) { - allocator->real->addSlave(arg0, arg1, arg2, arg3); + allocator->real->addSlave(arg0, arg1, arg2, arg3, arg4); } @@ -1431,9 +1431,9 @@ public: EXPECT_CALL(*this, updateFramework(_, _)) .WillRepeatedly(DoDefault()); - ON_CALL(*this, addSlave(_, _, _, _)) + ON_CALL(*this, addSlave(_, _, _, _, _)) .WillByDefault(InvokeAddSlave(this)); - EXPECT_CALL(*this, addSlave(_, _, _, _)) + EXPECT_CALL(*this, addSlave(_, _, _, _, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, removeSlave(_)) @@ -1514,9 +1514,10 @@ public: const FrameworkID&, const FrameworkInfo&)); - MOCK_METHOD4(addSlave, void( + MOCK_METHOD5(addSlave, void( const SlaveID&, const SlaveInfo&, + const Option<Unavailability>&, const Resources&, const hashmap<FrameworkID, Resources>&)); http://git-wip-us.apache.org/repos/asf/mesos/blob/ea48105a/src/tests/reservation_endpoints_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/reservation_endpoints_tests.cpp b/src/tests/reservation_endpoints_tests.cpp index dfab497..572a8d6 100644 --- a/src/tests/reservation_endpoints_tests.cpp +++ b/src/tests/reservation_endpoints_tests.cpp @@ -138,7 +138,7 @@ TEST_F(ReservationEndpointsTest, AvailableResources) ASSERT_SOME(master); Future<SlaveID> slaveId; - EXPECT_CALL(allocator, addSlave(_, _, _, _)) + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)) .WillOnce(DoAll(InvokeAddSlave(&allocator), FutureArg<0>(&slaveId))); @@ -231,7 +231,7 @@ TEST_F(ReservationEndpointsTest, ReserveOfferedResources) ASSERT_SOME(master); Future<SlaveID> slaveId; - EXPECT_CALL(allocator, addSlave(_, _, _, _)) + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)) .WillOnce(DoAll(InvokeAddSlave(&allocator), FutureArg<0>(&slaveId))); @@ -305,7 +305,7 @@ TEST_F(ReservationEndpointsTest, UnreserveOfferedResources) ASSERT_SOME(master); Future<SlaveID> slaveId; - EXPECT_CALL(allocator, addSlave(_, _, _, _)) + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)) .WillOnce(DoAll(InvokeAddSlave(&allocator), FutureArg<0>(&slaveId))); @@ -391,7 +391,7 @@ TEST_F(ReservationEndpointsTest, ReserveAvailableAndOfferedResources) ASSERT_SOME(master); Future<SlaveID> slaveId; - EXPECT_CALL(allocator, addSlave(_, _, _, _)) + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)) .WillOnce(DoAll(InvokeAddSlave(&allocator), FutureArg<0>(&slaveId))); @@ -533,7 +533,7 @@ TEST_F(ReservationEndpointsTest, UnreserveAvailableAndOfferedResources) ASSERT_SOME(master); Future<SlaveID> slaveId; - EXPECT_CALL(allocator, addSlave(_, _, _, _)) + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)) .WillOnce(DoAll(InvokeAddSlave(&allocator), FutureArg<0>(&slaveId))); @@ -684,7 +684,7 @@ TEST_F(ReservationEndpointsTest, InsufficientResources) ASSERT_SOME(master); Future<SlaveID> slaveId; - EXPECT_CALL(allocator, addSlave(_, _, _, _)) + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)) .WillOnce(DoAll(InvokeAddSlave(&allocator), FutureArg<0>(&slaveId))); @@ -726,7 +726,7 @@ TEST_F(ReservationEndpointsTest, NoHeader) ASSERT_SOME(master); Future<SlaveID> slaveId; - EXPECT_CALL(allocator, addSlave(_, _, _, _)) + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)) .WillOnce(DoAll(InvokeAddSlave(&allocator), FutureArg<0>(&slaveId))); @@ -776,7 +776,7 @@ TEST_F(ReservationEndpointsTest, BadCredentials) ASSERT_SOME(master); Future<SlaveID> slaveId; - EXPECT_CALL(allocator, addSlave(_, _, _, _)) + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)) .WillOnce(DoAll(InvokeAddSlave(&allocator), FutureArg<0>(&slaveId))); @@ -853,7 +853,7 @@ TEST_F(ReservationEndpointsTest, NoResources) ASSERT_SOME(master); Future<SlaveID> slaveId; - EXPECT_CALL(allocator, addSlave(_, _, _, _)) + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)) .WillOnce(DoAll(InvokeAddSlave(&allocator), FutureArg<0>(&slaveId))); @@ -888,7 +888,7 @@ TEST_F(ReservationEndpointsTest, NonMatchingPrincipal) ASSERT_SOME(master); Future<SlaveID> slaveId; - EXPECT_CALL(allocator, addSlave(_, _, _, _)) + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)) .WillOnce(DoAll(InvokeAddSlave(&allocator), FutureArg<0>(&slaveId))); http://git-wip-us.apache.org/repos/asf/mesos/blob/ea48105a/src/tests/reservation_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/reservation_tests.cpp b/src/tests/reservation_tests.cpp index aeee367..91fcf0d 100644 --- a/src/tests/reservation_tests.cpp +++ b/src/tests/reservation_tests.cpp @@ -418,7 +418,7 @@ TEST_F(ReservationTest, DropReserveTooLarge) slave::Flags slaveFlags = CreateSlaveFlags(); slaveFlags.resources = "cpus:1;mem:512"; - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave>> slave = StartSlave(slaveFlags); ASSERT_SOME(slave); @@ -509,7 +509,7 @@ TEST_F(ReservationTest, DropReserveStaticReservation) slave::Flags slaveFlags = CreateSlaveFlags(); slaveFlags.resources = "cpus(role):1;mem(role):512"; - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Try<PID<Slave>> slave = StartSlave(slaveFlags); ASSERT_SOME(slave); http://git-wip-us.apache.org/repos/asf/mesos/blob/ea48105a/src/tests/slave_recovery_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/slave_recovery_tests.cpp b/src/tests/slave_recovery_tests.cpp index 6aae14a..b636986 100644 --- a/src/tests/slave_recovery_tests.cpp +++ b/src/tests/slave_recovery_tests.cpp @@ -2150,7 +2150,7 @@ TYPED_TEST(SlaveRecoveryTest, ReconcileTasksMissingFromSlave) slave::Flags flags = this->CreateSlaveFlags(); - EXPECT_CALL(allocator, addSlave(_, _, _, _)); + EXPECT_CALL(allocator, addSlave(_, _, _, _, _)); Fetcher fetcher;
