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

Function validateTaskAndExecutorResources

src/master/validation.cpp:1476–1514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1474
1475
1476Option<Error> validateTaskAndExecutorResources(const TaskInfo& task)
1477{
1478 Resources total = task.resources();
1479 if (task.has_executor()) {
1480 total += task.executor().resources();
1481 }
1482
1483 Option<Error> error = resource::validate(total);
1484 if (error.isSome()) {
1485 return Error(
1486 "Task and its executor use invalid resources: " + error->message);
1487 }
1488
1489 // We perform the check for `has_executor()` again here because we needed to
1490 // validate the total resources before checking for overlapping ranges/sets.
1491 if (task.has_executor()) {
1492 if (resource::detectOverlappingSetAndRangeResources({
1493 task.resources(),
1494 task.executor().resources()})) {
1495 return Error("There are overlapping resources in the task resources " +
1496 stringify(task.resources()) + " and executor resources " +
1497 stringify(task.executor().resources()));
1498 }
1499 }
1500
1501 error = resource::validateUniquePersistenceID(total);
1502 if (error.isSome()) {
1503 return Error("Task and its executor use duplicate persistence ID: " +
1504 error->message);
1505 }
1506
1507 error = resource::validateRevocableAndNonRevocableResources(total);
1508 if (error.isSome()) {
1509 return Error("Task and its executor mix revocable and non-revocable"
1510 " resources: " + error->message);
1511 }
1512
1513 return None();
1514}
1515
1516
1517// Validates the `CommandInfo` contained within a `TaskInfo`.

Callers 2

TEST_FFunction · 0.85
validateExecutorFunction · 0.85

Calls 10

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

Tested by 1

TEST_FFunction · 0.68