You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2017/07/05 10:54:11 UTC
[3/4] mesos git commit: Updated `accept` to perform operation
adjustment in one place.
Updated `accept` to perform operation adjustment in one place.
It used to be that the minor adjustments that were made to operations
were done in various places across `accept` and `_accept`.
The "executor-injection" for LAUNCH_GROUP was at the beginning of
`accept`, "allocation-info-injection" for MULTI_ROLE was after offer
validation, and "health-check-injection" for LAUNCH was in `_accept`.
The `Master::accept` function is now broken down into distinct
"metrics accounting", "offer validation", "operation-adjustments", and
"authorization" stages.
Review: https://reviews.apache.org/r/60562
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/710b7217
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/710b7217
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/710b7217
Branch: refs/heads/master
Commit: 710b72179938cac2100c90277ce7ced5c8ca3401
Parents: 21de4b6
Author: Michael Park <mp...@apache.org>
Authored: Thu Jun 29 20:53:59 2017 -0700
Committer: Michael Park <mp...@apache.org>
Committed: Wed Jul 5 03:41:37 2017 -0700
----------------------------------------------------------------------
src/master/master.cpp | 133 +++++++++++++++++++++++++++------------------
1 file changed, 80 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/710b7217/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 9d5566b..da0a13b 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -3805,7 +3805,8 @@ void Master::accept(
{
CHECK_NOTNULL(framework);
- foreach (Offer::Operation& operation, *accept.mutable_operations()) {
+ // Bump metrics.
+ foreach (const Offer::Operation& operation, accept.operations()) {
if (operation.type() == Offer::Operation::LAUNCH) {
if (operation.launch().task_infos().size() > 0) {
++metrics->messages_launch_tasks;
@@ -3815,22 +3816,9 @@ void Master::accept(
<< " in ACCEPT call for framework " << framework->id()
<< " as the launch operation specified no tasks";
}
- } else if (operation.type() == Offer::Operation::LAUNCH_GROUP) {
- const ExecutorInfo& executor = operation.launch_group().executor();
-
- TaskGroupInfo* taskGroup =
- operation.mutable_launch_group()->mutable_task_group();
-
- // Mutate `TaskInfo` to include `ExecutorInfo` to make it easy
- // for operator API and WebUI to get access to the corresponding
- // executor for tasks in the task group.
- foreach (TaskInfo& task, *taskGroup->mutable_tasks()) {
- if (!task.has_executor()) {
- task.mutable_executor()->CopyFrom(executor);
- }
- }
}
+ // TODO(mpark): Add metrics for LAUNCH_GROUP operation.
// TODO(jieyu): Add metrics for non launch operations.
}
@@ -3937,14 +3925,85 @@ void Master::accept(
return;
}
- CHECK_SOME(allocationInfo);
-
- // With the addition of the MULTI_ROLE capability, the resources
- // within an offer now contain an `AllocationInfo`. We therefore
- // inject the offer's allocation info into the operation's
- // resources if the scheduler has not done so already.
+ // We make various adjustments to the `Offer::Operation`s,
+ // typically for backward/forward compatibility.
+ // TODO(mpark): Pull this out to a master normalization utility.
foreach (Offer::Operation& operation, *accept.mutable_operations()) {
+ // With the addition of the MULTI_ROLE capability, the resources
+ // within an offer now contain an `AllocationInfo`. We therefore
+ // inject the offer's allocation info into the operation's
+ // resources if the scheduler has not done so already.
+ CHECK_SOME(allocationInfo);
protobuf::injectAllocationInfo(&operation, allocationInfo.get());
+
+ switch (operation.type()) {
+ case Offer::Operation::RESERVE:
+ case Offer::Operation::UNRESERVE:
+ case Offer::Operation::CREATE:
+ case Offer::Operation::DESTROY: {
+ // No-op.
+ break;
+ }
+ case Offer::Operation::LAUNCH: {
+ foreach (
+ TaskInfo& task, *operation.mutable_launch()->mutable_task_infos()) {
+ // TODO(haosdent): Once we have internal `TaskInfo` separate from
+ // the v0 `TaskInfo` (see MESOS-6268), consider extracting the
+ // following adaptation code into devolve methods from v0 and v1
+ // `TaskInfo` to internal `TaskInfo`.
+ //
+ // Make a copy of the original task so that we can fill the missing
+ // `framework_id` in `ExecutorInfo` if needed. This field was added
+ // to the API later and thus was made optional.
+ if (task.has_executor() && !task.executor().has_framework_id()) {
+ task.mutable_executor()->mutable_framework_id()->CopyFrom(
+ framework->id());
+ }
+
+ // For backwards compatibility with the v0 and v1 API, when
+ // the type of the health check is not specified, determine
+ // its type from the `http` and `command` fields.
+ //
+ // TODO(haosdent): Remove this after the deprecation cycle which
+ // starts in 2.0.
+ if (task.has_health_check() && !task.health_check().has_type()) {
+ LOG(WARNING) << "The type of health check is not set; use of "
+ << "'HealthCheck' without specifying 'type' will be "
+ << "deprecated in Mesos 2.0";
+
+ const HealthCheck& healthCheck = task.health_check();
+ if (healthCheck.has_command() && !healthCheck.has_http()) {
+ task.mutable_health_check()->set_type(HealthCheck::COMMAND);
+ } else if (healthCheck.has_http() && !healthCheck.has_command()) {
+ task.mutable_health_check()->set_type(HealthCheck::HTTP);
+ }
+ }
+ }
+
+ break;
+ }
+ case Offer::Operation::LAUNCH_GROUP: {
+ const ExecutorInfo& executor = operation.launch_group().executor();
+
+ TaskGroupInfo* taskGroup =
+ operation.mutable_launch_group()->mutable_task_group();
+
+ // Mutate `TaskInfo` to include `ExecutorInfo` to make it easy
+ // for operator API and WebUI to get access to the corresponding
+ // executor for tasks in the task group.
+ foreach (TaskInfo& task, *taskGroup->mutable_tasks()) {
+ if (!task.has_executor()) {
+ task.mutable_executor()->CopyFrom(executor);
+ }
+ }
+
+ break;
+ }
+ case Offer::Operation::UNKNOWN: {
+ // No-op.
+ break;
+ }
+ }
}
CHECK_SOME(slaveId);
@@ -4556,38 +4615,6 @@ void Master::_accept(
// Validate the task.
- // TODO(haosdent): Once we have internal `TaskInfo` separate from
- // the v0 `TaskInfo` (see MESOS-6268), consider extracting the
- // following adaptation code into devolve methods from v0 and v1
- // `TaskInfo` to internal `TaskInfo`.
- //
- // Make a copy of the original task so that we can fill the missing
- // `framework_id` in `ExecutorInfo` if needed. This field was added
- // to the API later and thus was made optional.
- if (task.has_executor() && !task.executor().has_framework_id()) {
- task.mutable_executor()->mutable_framework_id()->CopyFrom(
- framework->id());
- }
-
- // For backwards compatibility with the v0 and v1 API, when
- // the type of the health check is not specified, determine
- // its type from the `http` and `command` fields.
- //
- // TODO(haosdent): Remove this after the deprecation cycle which
- // starts in 2.0.
- if (task.has_health_check() && !task.health_check().has_type()) {
- LOG(WARNING) << "The type of health check is not set; use of "
- << "'HealthCheck' without specifying 'type' will be "
- << "deprecated in Mesos 2.0";
-
- const HealthCheck& healthCheck = task.health_check();
- if (healthCheck.has_command() && !healthCheck.has_http()) {
- task.mutable_health_check()->set_type(HealthCheck::COMMAND);
- } else if (healthCheck.has_http() && !healthCheck.has_command()) {
- task.mutable_health_check()->set_type(HealthCheck::HTTP);
- }
- }
-
// We add back offered shared resources for validation even if they
// are already consumed by other tasks in the same ACCEPT call. This
// allows these tasks to use more copies of the same shared resource