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

Function validateAndUpgradeResources

src/common/resources_utils.cpp:608–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606
607
608Option<Error> validateAndUpgradeResources(Offer::Operation* operation)
609{
610 CHECK_NOTNULL(operation);
611
612 switch (operation->type()) {
613 case Offer::Operation::RESERVE: {
614 // TODO(mpark): Once we perform a sanity check validation for
615 // offer operations as specified in MESOS-7760, this should no
616 // longer have to be handled in this function.
617 if (!operation->has_reserve()) {
618 return Error(
619 "A RESERVE offer operation must have"
620 " the Offer.Operation.reserve field set.");
621 }
622
623 Option<Error> error =
624 Resources::validate(operation->reserve().resources());
625
626 if (error.isSome()) {
627 return error;
628 }
629
630 error = Resources::validate(operation->reserve().source());
631
632 if (error.isSome()) {
633 return error;
634 }
635
636 break;
637 }
638 case Offer::Operation::UNRESERVE: {
639 // TODO(mpark): Once we perform a sanity check validation for
640 // offer operations as specified in MESOS-7760, this should no
641 // longer have to be handled in this function.
642 if (!operation->has_unreserve()) {
643 return Error(
644 "An UNRESERVE offer operation must have"
645 " the Offer.Operation.unreserve field set.");
646 }
647
648 Option<Error> error =
649 Resources::validate(operation->unreserve().resources());
650
651 if (error.isSome()) {
652 return error;
653 }
654
655 break;
656 }
657 case Offer::Operation::CREATE: {
658 // TODO(mpark): Once we perform a sanity check validation for
659 // offer operations as specified in MESOS-7760, this should no
660 // longer have to be handled in this function.
661 if (!operation->has_create()) {
662 return Error(
663 "A CREATE offer operation must have"
664 " the Offer.Operation.create field set.");
665 }

Callers 7

_createVolumesMethod · 0.85
_destroyVolumesMethod · 0.85
growVolumeMethod · 0.85
shrinkVolumeMethod · 0.85
_reserveMethod · 0.85
_unreserveMethod · 0.85
foreachFunction · 0.85

Calls 12

upgradeResourcesFunction · 0.85
NoneClass · 0.85
typeMethod · 0.80
executorMethod · 0.80
validateFunction · 0.70
ErrorFunction · 0.50
resourcesMethod · 0.45
reserveMethod · 0.45
isSomeMethod · 0.45
unreserveMethod · 0.45
createMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected