| 6891 | |
| 6892 | |
| 6893 | void Master::__reregisterSlave( |
| 6894 | const UPID& pid, |
| 6895 | ReregisterSlaveMessage&& reregisterSlaveMessage, |
| 6896 | const Future<bool>& future) |
| 6897 | { |
| 6898 | const SlaveInfo& slaveInfo = reregisterSlaveMessage.slave(); |
| 6899 | CHECK(slaves.reregistering.contains(slaveInfo.id())); |
| 6900 | |
| 6901 | if (future.isFailed()) { |
| 6902 | LOG(FATAL) << "Failed to update registry for agent " << slaveInfo.id() |
| 6903 | << " at " << pid << " (" << slaveInfo.hostname() << "): " |
| 6904 | << future.failure(); |
| 6905 | } |
| 6906 | |
| 6907 | CHECK(!future.isDiscarded()); |
| 6908 | |
| 6909 | // Neither the `UpdateSlave` nor `MarkSlaveReachable` registry operations |
| 6910 | // should ever fail. |
| 6911 | CHECK(future.get()); |
| 6912 | |
| 6913 | if (slaves.markingGone.contains(slaveInfo.id())) { |
| 6914 | LOG(INFO) |
| 6915 | << "Ignoring reregister agent message from agent " |
| 6916 | << slaveInfo.id() << " at " << pid << " (" |
| 6917 | << slaveInfo.hostname() << ") as a gone operation is already in progress"; |
| 6918 | |
| 6919 | slaves.reregistering.erase(slaveInfo.id()); |
| 6920 | return; |
| 6921 | } |
| 6922 | |
| 6923 | if (slaves.gone.contains(slaveInfo.id())) { |
| 6924 | LOG(WARNING) << "Refusing re-registration of agent at " << pid |
| 6925 | << " because it is already marked gone"; |
| 6926 | |
| 6927 | ShutdownMessage message; |
| 6928 | message.set_message("Agent has been marked gone"); |
| 6929 | send(pid, message); |
| 6930 | |
| 6931 | slaves.reregistering.erase(slaveInfo.id()); |
| 6932 | return; |
| 6933 | } |
| 6934 | |
| 6935 | VLOG(1) << "Re-admitted agent " << slaveInfo.id() << " at " << pid |
| 6936 | << " (" << slaveInfo.hostname() << ")"; |
| 6937 | |
| 6938 | // For agents without the MULTI_ROLE capability, |
| 6939 | // we need to inject the allocation role inside |
| 6940 | // the task and executor resources; |
| 6941 | auto injectAllocationInfo = []( |
| 6942 | RepeatedPtrField<Resource>* resources, |
| 6943 | const FrameworkInfo& frameworkInfo) |
| 6944 | { |
| 6945 | set<string> roles = protobuf::framework::getRoles(frameworkInfo); |
| 6946 | |
| 6947 | foreach (Resource& resource, *resources) { |
| 6948 | if (!resource.has_allocation_info()) { |
| 6949 | if (roles.size() != 1) { |
| 6950 | LOG(FATAL) << "Missing 'Resource.AllocationInfo' for resources" |
nothing calls this directly
no test coverage detected