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

Function validateAllocatedToSingleRole

src/master/validation.cpp:978–1004  ·  view source on GitHub ↗

Validates that all the given resources are allocated to same role.

Source from the content-addressed store, hash-verified

976
977// Validates that all the given resources are allocated to same role.
978Option<Error> validateAllocatedToSingleRole(const Resources& resources)
979{
980 Option<string> role;
981
982 foreach (const Resource& resource, resources) {
983 // Note that the master normalizes `Offer::Operation` resources
984 // to have allocation info set, so we can validate it here.
985 if (!resource.allocation_info().has_role()) {
986 return Error("The resources are not allocated to a role");
987 }
988
989 string _role = resource.allocation_info().role();
990
991 if (role.isNone()) {
992 role = _role;
993 continue;
994 }
995
996 if (_role != role.get()) {
997 return Error("The resources have multiple allocation roles"
998 " ('" + _role + "' and '" + role.get() + "')"
999 " but only one allocation role is allowed");
1000 }
1001 }
1002
1003 return None();
1004}
1005
1006
1007bool detectOverlappingSetAndRangeResources(

Callers 2

validateResourcesFunction · 0.85
validateFunction · 0.85

Calls 1

NoneClass · 0.85

Tested by

no test coverage detected