| 352 | |
| 353 | |
| 354 | Option<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)) { |