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

Method _registerSlave

src/master/master.cpp:6297–6456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6295
6296
6297void Master::_registerSlave(
6298 const UPID& pid,
6299 RegisterSlaveMessage&& registerSlaveMessage,
6300 const Option<Principal>& principal,
6301 const Future<bool>& authorized)
6302{
6303 CHECK(!authorized.isDiscarded());
6304 CHECK(slaves.registering.contains(pid));
6305
6306 const SlaveInfo& slaveInfo = registerSlaveMessage.slave();
6307
6308 Option<string> authorizationError = None();
6309
6310 if (authorized.isFailed()) {
6311 authorizationError = "Authorization failure: " + authorized.failure();
6312 } else if (!authorized.get()) {
6313 authorizationError =
6314 "Not authorized to register agent providing resources "
6315 "'" + stringify(Resources(slaveInfo.resources())) + "' " +
6316 (principal.isSome()
6317 ? "with principal '" + stringify(principal.get()) + "'"
6318 : "without a principal");
6319 }
6320
6321 if (authorizationError.isSome()) {
6322 LOG(WARNING) << "Refusing registration of agent at " << pid
6323 << " (" << slaveInfo.hostname() << ")"
6324 << ": " << authorizationError.get();
6325
6326 slaves.registering.erase(pid);
6327 return;
6328 }
6329
6330 VLOG(1) << "Authorized registration of agent at " << pid
6331 << " (" << slaveInfo.hostname() << ")";
6332
6333 MachineID machineId;
6334 machineId.set_hostname(slaveInfo.hostname());
6335 machineId.set_ip(stringify(pid.address.ip));
6336
6337 // Slaves are not allowed to register while the machine they are on is in
6338 // `DOWN` mode.
6339 if (machines.contains(machineId) &&
6340 machines[machineId].info.mode() == MachineInfo::DOWN) {
6341 LOG(WARNING) << "Refusing registration of agent at " << pid
6342 << " because the machine '" << machineId << "' that it is "
6343 << "running on is `DOWN`";
6344
6345 ShutdownMessage message;
6346 message.set_message("Machine is `DOWN`");
6347 send(pid, message);
6348
6349 slaves.registering.erase(pid);
6350 return;
6351 }
6352
6353 // Ignore registration attempts by agents running old Mesos versions.
6354 // We expect that the agent's version is in SemVer format; if the

Callers

nothing calls this directly

Calls 15

NoneClass · 0.85
deferFunction · 0.85
isDiscardedMethod · 0.80
isFailedMethod · 0.80
failureMethod · 0.80
versionMethod · 0.80
CopyFromMethod · 0.80
errorMethod · 0.65
stringifyFunction · 0.50
ResourcesClass · 0.50
sendFunction · 0.50
parseFunction · 0.50

Tested by

no test coverage detected