MCPcopy Create free account
hub / github.com/apache/mesos / updateOperation

Method updateOperation

src/master/master.cpp:11385–11600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11383
11384
11385void Master::updateOperation(
11386 Operation* operation,
11387 const UpdateOperationStatusMessage& update,
11388 bool convertResources)
11389{
11390 CHECK_NOTNULL(operation);
11391
11392 const OperationStatus& status =
11393 update.has_latest_status() ? update.latest_status() : update.status();
11394
11395 LOG(INFO) << "Updating the state of operation '" << operation->info().id()
11396 << "' (uuid: " << update.operation_uuid() << ") for"
11397 << (operation->has_framework_id()
11398 ? " framework " + stringify(operation->framework_id())
11399 : " an operator API call")
11400 << " (latest state: " << operation->latest_status().state()
11401 << ", status update state: " << status.state() << ")";
11402
11403 metrics->transitionOperationState(
11404 operation->info().type(),
11405 operation->latest_status().state(),
11406 status.state());
11407
11408 // Whether the operation has just become terminated.
11409 const bool terminated =
11410 !protobuf::isTerminalState(operation->latest_status().state()) &&
11411 protobuf::isTerminalState(status.state());
11412
11413 // If the operation has already transitioned to a terminal state,
11414 // do not update its state.
11415 if (!protobuf::isTerminalState(operation->latest_status().state())) {
11416 operation->mutable_latest_status()->CopyFrom(status);
11417 }
11418
11419 // TODO(gkleiman): Revisit the de-duplication logic (MESOS-8441) - if two
11420 // different terminal statuses arrive, we could end up with different states
11421 // in `latest_status` and the front of statuses list.
11422 if (operation->statuses().empty() ||
11423 *(operation->statuses().rbegin()) != status) {
11424 operation->add_statuses()->CopyFrom(status);
11425 }
11426
11427 if (!terminated) {
11428 return;
11429 }
11430
11431 // Update resource accounting in the master and in the allocator.
11432 // NOTE: For the "old" operations (RESERVE, UNRESERVE, CREATE,
11433 // DESTROY), the master speculatively assumes that the operation
11434 // will be successful when it accepts the operations. Therefore, we
11435 // don't need to update the resource accounting for those types of
11436 // operations in the master and in the allocator states upon
11437 // receiving a terminal status update.
11438 if (protobuf::isSpeculativeOperation(operation->info())) {
11439 return;
11440 }
11441
11442 // We currently do not support non-speculated operations not

Callers

nothing calls this directly

Calls 15

isTerminalStateFunction · 0.85
isSpeculativeOperationFunction · 0.85
getConsumedResourcesFunction · 0.85
NoneClass · 0.85
infoMethod · 0.80
typeMethod · 0.80
CopyFromMethod · 0.80
stringifyFunction · 0.50
ResourceConversionClass · 0.50
statusMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected