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

Function validateUpdate

src/master/validation.cpp:592–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590
591
592Option<Error> validateUpdate(
593 const FrameworkInfo& oldInfo,
594 const FrameworkInfo& newInfo)
595{
596 Option<string> oldPrincipal = None();
597 if (oldInfo.has_principal()) {
598 oldPrincipal = oldInfo.principal();
599 }
600
601 Option<string> newPrincipal = None();
602 if (newInfo.has_principal()) {
603 newPrincipal = newInfo.principal();
604 }
605
606 if (oldPrincipal != newPrincipal) {
607 // We should not expose the old principal to the 'scheduler' which tries
608 // to subscribe with a known framework ID but another principal.
609 // However, it still should be possible for the people having access to
610 // the master to understand what is going on, hence the log message.
611 LOG(WARNING)
612 << "Framework " << oldInfo.id() << " which had a principal "
613 << " '" << oldPrincipal.getOrElse("<NONE>") << "'"
614 << " tried to (re)subscribe with a new principal "
615 << " '" << newPrincipal.getOrElse("<NONE>") << "'";
616
617 return Error("Changing framework's principal is not allowed.");
618 }
619
620 if (newInfo.user() != oldInfo.user()) {
621 return Error(
622 "Updating 'FrameworkInfo.user' is unsupported"
623 "; attempted to update from '" + oldInfo.user() + "'"
624 " to '" + newInfo.user() + "'");
625 }
626
627 if (newInfo.checkpoint() != oldInfo.checkpoint()) {
628 return Error(
629 "Updating 'FrameworkInfo.checkpoint' is unsupported"
630 "; attempted to update"
631 " from '" + stringify(oldInfo.checkpoint()) + "'"
632 " to '" + stringify(newInfo.checkpoint()) + "'");
633 }
634
635 return None();
636}
637
638
639void preserveImmutableFields(

Callers 3

TEST_FFunction · 0.85
_subscribeMethod · 0.85
updateFrameworkMethod · 0.85

Calls 8

NoneClass · 0.85
principalMethod · 0.80
getOrElseMethod · 0.80
userMethod · 0.80
checkpointMethod · 0.80
ErrorFunction · 0.50
stringifyFunction · 0.50
idMethod · 0.45

Tested by 1

TEST_FFunction · 0.68