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

Method updateSlave

src/master/master.cpp:7518–8043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7516
7517
7518void Master::updateSlave(UpdateSlaveMessage&& message)
7519{
7520 ++metrics->messages_update_slave;
7521
7522 upgradeResources(&message);
7523
7524 const SlaveID& slaveId = message.slave_id();
7525
7526 if (slaves.removed.get(slaveId).isSome()) {
7527 // If the slave has been removed, drop the status update. The
7528 // master is no longer trying to health check this slave; when the
7529 // slave realizes it hasn't received any pings from the master, it
7530 // will eventually try to reregister.
7531 LOG(WARNING) << "Ignoring update on removed agent " << slaveId;
7532 return;
7533 }
7534
7535 Slave* slave = slaves.registered.get(slaveId);
7536
7537 if (slave == nullptr) {
7538 LOG(WARNING) << "Ignoring update on removed agent " << slaveId;
7539 return;
7540 }
7541
7542 // NOTE: We must *first* update the agent's resources before we
7543 // recover the resources. If we recovered the resources first,
7544 // an allocation could trigger between recovering resources and
7545 // updating the agent in the allocator. This would lead us to
7546 // re-send out the stale oversubscribed resources!
7547
7548 // If agent does not specify the `update_oversubscribed_resources`
7549 // field, we assume we should set `oversubscribedResources` to be
7550 // backwards-compatibility with older agents (version < 1.5).
7551 const bool hasOversubscribed =
7552 !message.has_update_oversubscribed_resources() ||
7553 message.update_oversubscribed_resources();
7554
7555 Option<Resources> newOversubscribed;
7556
7557 if (hasOversubscribed) {
7558 const Resources& oversubscribedResources =
7559 message.oversubscribed_resources();
7560
7561 LOG(INFO) << "Received update of agent " << *slave << " with total"
7562 << " oversubscribed resources " << oversubscribedResources;
7563
7564 newOversubscribed = oversubscribedResources;
7565 }
7566
7567 Resources newResourceProviderResources;
7568 if (message.has_resource_providers()) {
7569 foreach (
7570 const UpdateSlaveMessage::ResourceProvider& resourceProvider,
7571 message.resource_providers().providers()) {
7572 newResourceProviderResources += resourceProvider.total_resources();
7573 }
7574 }
7575

Callers 6

TEST_FFunction · 0.45
foreachFunction · 0.45
ACTION_PFunction · 0.45
___reregisterSlaveMethod · 0.45
foreachFunction · 0.45
updateOperationMethod · 0.45

Calls 15

upgradeResourcesFunction · 0.85
copyFunction · 0.85
getOrElseMethod · 0.80
foreachFunction · 0.70
sendFunction · 0.50
isSomeMethod · 0.45
getMethod · 0.45
filterMethod · 0.45
nonRevocableMethod · 0.45
revocableMethod · 0.45
isNoneMethod · 0.45
sizeMethod · 0.45

Tested by 3

TEST_FFunction · 0.36
foreachFunction · 0.36
ACTION_PFunction · 0.36