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

Function reregisterSlave

src/master/validation.cpp:354–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352
353
354Option<Error> reregisterSlave(const ReregisterSlaveMessage& message)
355{
356 hashset<FrameworkID> frameworkIDs;
357 hashset<pair<FrameworkID, ExecutorID>> executorIDs;
358
359 const SlaveInfo& slaveInfo = message.slave();
360 Option<Error> error = validateSlaveInfo(slaveInfo);
361 if (error.isSome()) {
362 return error.get();
363 }
364
365 foreach (const Resource& resource, message.checkpointed_resources()) {
366 Option<Error> error = Resources::validate(resource);
367 if (error.isSome()) {
368 return error.get();
369 }
370 }
371
372 foreach (const FrameworkInfo& framework, message.frameworks()) {
373 Option<Error> error = validation::framework::validate(framework);
374 if (error.isSome()) {
375 return error.get();
376 }
377
378 if (frameworkIDs.contains(framework.id())) {
379 return Error("Framework has a duplicate FrameworkID: '" +
380 stringify(framework.id()) + "'");
381 }
382
383 frameworkIDs.insert(framework.id());
384 }
385
386 foreach (const ExecutorInfo& executor, message.executor_infos()) {
387 Option<Error> error = validation::executor::validate(executor);
388 if (error.isSome()) {
389 return error.get();
390 }
391
392 // We don't use `internal::validateResources` here because that
393 // includes the `validateAllocatedToSingleRole` check, which is
394 // not valid for agent re-registration.
395 //
396 // TODO(neilc): Consider refactoring `internal::validateResources`
397 // to allow some but not all checks to be applied, or else inject
398 // allocation info into executor resources here.
399 error = Resources::validate(executor.resources());
400 if (error.isSome()) {
401 return error.get();
402 }
403
404 if (!frameworkIDs.contains(executor.framework_id())) {
405 return Error("Executor has an invalid FrameworkID '" +
406 stringify(executor.framework_id()) + "'");
407 }
408
409 if (executor.has_executor_id()) {
410 auto id = std::make_pair(executor.framework_id(), executor.executor_id());
411 if (executorIDs.contains(id)) {

Callers 2

TEST_FFunction · 0.85
reregisterSlaveMethod · 0.85

Calls 4

validateSlaveInfoFunction · 0.85
NoneClass · 0.85
isSomeMethod · 0.45
getMethod · 0.45

Tested by 1

TEST_FFunction · 0.68