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

Method recover

src/slave/slave.cpp:7736–7985  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7734
7735
7736Future<Nothing> Slave::recover(const Try<state::State>& state)
7737{
7738 if (state.isError()) {
7739 return Failure(state.error());
7740 }
7741
7742 LOG(INFO) << "Finished recovering checkpointed state from '" << metaDir
7743 << "', beginning agent recovery";
7744
7745 Option<ResourcesState> resourcesState = state->resources;
7746 Option<SlaveState> slaveState = state->slave;
7747
7748 // With the addition of frameworks with multiple roles, we
7749 // need to inject the allocated role into each allocated
7750 // `Resource` object that we've persisted. Note that we
7751 // also must do this for MULTI_ROLE frameworks since they
7752 // may have tasks that were present before the framework
7753 // upgraded into MULTI_ROLE.
7754 auto injectAllocationInfo = [](
7755 RepeatedPtrField<Resource>* resources,
7756 const FrameworkInfo& frameworkInfo) {
7757 set<string> roles = protobuf::framework::getRoles(frameworkInfo);
7758
7759 bool injectedAllocationInfo = false;
7760 foreach (Resource& resource, *resources) {
7761 if (!resource.has_allocation_info()) {
7762 if (roles.size() != 1) {
7763 LOG(FATAL) << "Missing 'Resource.AllocationInfo' for resources"
7764 << " allocated to MULTI_ROLE framework"
7765 << " '" << frameworkInfo.name() << "'";
7766 }
7767
7768 resource.mutable_allocation_info()->set_role(*roles.begin());
7769 injectedAllocationInfo = true;
7770 }
7771 }
7772
7773 return injectedAllocationInfo;
7774 };
7775
7776 // In order to allow frameworks to change their role(s), we need to keep
7777 // track of the fact that the resources used to be implicitly allocated to
7778 // `FrameworkInfo.role` before the agent upgrade. To this end, we inject
7779 // the `AllocationInfo` to the resources in `ExecutorState` and `TaskState`,
7780 // and re-checkpoint them if necessary.
7781
7782 hashset<ExecutorID> injectedExecutors;
7783 hashmap<ExecutorID, hashset<TaskID>> injectedTasks;
7784
7785 if (slaveState.isSome()) {
7786 foreachvalue (FrameworkState& frameworkState, slaveState->frameworks) {
7787 if (!frameworkState.info.isSome()) {
7788 continue;
7789 }
7790
7791 foreachvalue (ExecutorState& executorState, frameworkState.executors) {
7792 if (!executorState.info.isSome()) {
7793 continue;

Callers 4

_recoverContainerizerMethod · 0.45
_recoverOperationsMethod · 0.45

Calls 15

FailureClass · 0.85
getRolesFunction · 0.85
injectAllocationInfoFunction · 0.85
getResourceStatePathFunction · 0.85
getResourcesTargetPathFunction · 0.85
getResourcesInfoPathFunction · 0.85
NoneClass · 0.85
getLatestSlavePathFunction · 0.85
deferFunction · 0.85
insertMethod · 0.80

Tested by

no test coverage detected