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

Function validateExecutor

src/master/validation.cpp:1655–1769  ·  view source on GitHub ↗

Validates `Task.executor` if it exists.

Source from the content-addressed store, hash-verified

1653
1654// Validates `Task.executor` if it exists.
1655Option<Error> validateExecutor(
1656 const TaskInfo& task,
1657 Framework* framework,
1658 Slave* slave,
1659 const Resources& offered)
1660{
1661 CHECK_NOTNULL(framework);
1662 CHECK_NOTNULL(slave);
1663
1664 if (task.has_executor() == task.has_command()) {
1665 return Error(
1666 "Task should have at least one (but not both) of CommandInfo or "
1667 "ExecutorInfo present");
1668 }
1669
1670 Resources total = task.resources();
1671
1672 Option<Error> error = None();
1673
1674 if (task.has_executor()) {
1675 const ExecutorInfo& executor = task.executor();
1676
1677 // Do the general validation first.
1678 error = executor::internal::validate(executor, framework, slave);
1679 if (error.isSome()) {
1680 return error;
1681 }
1682
1683 // Now do specific validation when an executor is specified on `Task`.
1684
1685 // TODO(vinod): Revisit this when we allow schedulers to explicitly
1686 // specify 'DEFAULT' executor in the `LAUNCH` operation.
1687
1688 if (executor.has_type() && executor.type() != ExecutorInfo::CUSTOM) {
1689 return Error("'ExecutorInfo.type' must be 'CUSTOM'");
1690 }
1691
1692 // While `ExecutorInfo.command` is optional in the protobuf,
1693 // semantically it is still required for backwards compatibility.
1694 if (!executor.has_command()) {
1695 return Error("'ExecutorInfo.command' must be set");
1696 }
1697
1698 // TODO(martin): MESOS-1807. Return Error instead of logging a
1699 // warning.
1700 const Resources& executorResources = executor.resources();
1701
1702 // Ensure there are no shared resources in the executor resources.
1703 //
1704 // TODO(anindya_sinha): For simplicity we currently don't
1705 // allow shared resources in ExecutorInfo. See comments in
1706 // `HierarchicalAllocatorProcess::updateAllocation()` for more
1707 // details. Remove this check once we start supporting it.
1708 if (!executorResources.shared().empty()) {
1709 return Error(
1710 "Executor resources " + stringify(executorResources) +
1711 " should not contain any shared resources");
1712 }

Callers

nothing calls this directly

Calls 15

NoneClass · 0.85
executorMethod · 0.80
typeMethod · 0.80
commandMethod · 0.80
validateFunction · 0.70
validateCommandInfoFunction · 0.70
ErrorFunction · 0.50
stringifyFunction · 0.50
resourcesMethod · 0.45
isSomeMethod · 0.45

Tested by

no test coverage detected