| 10156 | |
| 10157 | |
| 10158 | void Master::connectAndActivateRecoveredFramework( |
| 10159 | Framework* framework, |
| 10160 | const Option<UPID>& pid, |
| 10161 | const Option<StreamingHttpConnection<v1::scheduler::Event>>& http, |
| 10162 | const Owned<ObjectApprovers>& objectApprovers) |
| 10163 | { |
| 10164 | // Exactly one of `pid` or `http` must be provided. |
| 10165 | CHECK(pid.isSome() != http.isSome()); |
| 10166 | |
| 10167 | CHECK_NOTNULL(framework); |
| 10168 | CHECK(framework->recovered()); |
| 10169 | CHECK(framework->offers.empty()); |
| 10170 | CHECK(framework->inverseOffers.empty()); |
| 10171 | CHECK(framework->pid().isNone()); |
| 10172 | CHECK(framework->http().isNone()); |
| 10173 | |
| 10174 | // Updating `registeredTime` here is debatable: ideally, |
| 10175 | // `registeredTime` would be the time at which the framework first |
| 10176 | // registered with the master. However, we cannot determine this |
| 10177 | // because the time at which a framework first registered is not |
| 10178 | // persisted across master failover. |
| 10179 | framework->registeredTime = Clock::now(); |
| 10180 | framework->reregisteredTime = Clock::now(); |
| 10181 | |
| 10182 | // Update the framework's connection state. |
| 10183 | if (pid.isSome()) { |
| 10184 | framework->updateConnection(pid.get(), objectApprovers); |
| 10185 | link(pid.get()); |
| 10186 | } else { |
| 10187 | framework->updateConnection(http.get(), objectApprovers); |
| 10188 | http->closed() |
| 10189 | .onAny(defer(self(), &Self::exited, framework->id(), http.get())); |
| 10190 | } |
| 10191 | |
| 10192 | CHECK(framework->activate()) |
| 10193 | << "RECOVERED framework is expected not to be active"; |
| 10194 | |
| 10195 | allocator->activateFramework(framework->id()); |
| 10196 | |
| 10197 | // Export framework metrics if a principal is specified in `FrameworkInfo`. |
| 10198 | Option<string> principal = framework->info.has_principal() |
| 10199 | ? Option<string>(framework->info.principal()) |
| 10200 | : None(); |
| 10201 | |
| 10202 | if (framework->pid().isSome()) { |
| 10203 | CHECK(!frameworks.principals.contains(framework->pid().get())); |
| 10204 | frameworks.principals.put(framework->pid().get(), principal); |
| 10205 | } |
| 10206 | |
| 10207 | // We expect the framework metrics for this principal to be created |
| 10208 | // when the framework is recovered. This implies that the framework |
| 10209 | // principal cannot change on re-registration, which is currently |
| 10210 | // the case (MESOS-2842). |
| 10211 | if (principal.isSome()) { |
| 10212 | CHECK(metrics->frameworks.contains(principal.get())); |
| 10213 | } |
| 10214 | |
| 10215 | if (pid.isSome()) { |
nothing calls this directly
no test coverage detected