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

Method detected

src/slave/slave.cpp:1441–1541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1439
1440
1441void Slave::detected(const Future<Option<MasterInfo>>& _master)
1442{
1443 CHECK(state == DISCONNECTED ||
1444 state == RUNNING ||
1445 state == TERMINATING) << state;
1446
1447 if (state != TERMINATING) {
1448 state = DISCONNECTED;
1449 }
1450
1451 // Pause the status updates.
1452 taskStatusUpdateManager->pause();
1453 operationStatusUpdateManager.pause();
1454
1455 if (_master.isFailed()) {
1456 EXIT(EXIT_FAILURE) << "Failed to detect a master: " << _master.failure();
1457 }
1458
1459 Option<MasterInfo> latest;
1460
1461 if (_master.isDiscarded()) {
1462 LOG(INFO) << "Re-detecting master";
1463 latest = None();
1464 master = None();
1465 } else if (_master->isNone()) {
1466 LOG(INFO) << "Lost leading master";
1467 latest = None();
1468 master = None();
1469 } else {
1470 latest = _master.get();
1471 master = UPID(latest->pid());
1472
1473 LOG(INFO) << "New master detected at " << master.get();
1474
1475 // Cancel the pending registration timer to avoid spurious attempts
1476 // at reregistration. `Clock::cancel` is idempotent, so this call
1477 // is safe even if no timer is active or pending.
1478 Clock::cancel(agentRegistrationTimer);
1479
1480 if (state == TERMINATING) {
1481 LOG(INFO) << "Skipping registration because agent is terminating";
1482 return;
1483 }
1484
1485 if (requiredMasterCapabilities.agentUpdate) {
1486 protobuf::master::Capabilities masterCapabilities(
1487 latest->capabilities());
1488
1489 if (!masterCapabilities.agentUpdate) {
1490 EXIT(EXIT_FAILURE) <<
1491 "Agent state changed on restart, but the detected master lacks the "
1492 "AGENT_UPDATE capability. Refusing to connect.";
1493 return;
1494 }
1495
1496 if (dynamic_cast<mesos::master::detector::StandaloneMasterDetector*>(
1497 detector)) {
1498 LOG(WARNING) <<

Callers

nothing calls this directly

Calls 15

NoneClass · 0.85
randomFunction · 0.85
minFunction · 0.85
deferFunction · 0.85
isFailedMethod · 0.80
failureMethod · 0.80
isDiscardedMethod · 0.80
UPIDClass · 0.50
delayFunction · 0.50
pauseMethod · 0.45
isNoneMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected