| 6215 | |
| 6216 | |
| 6217 | void Master::registerSlave( |
| 6218 | const UPID& from, |
| 6219 | RegisterSlaveMessage&& registerSlaveMessage) |
| 6220 | { |
| 6221 | ++metrics->messages_register_slave; |
| 6222 | |
| 6223 | if (authenticating.contains(from)) { |
| 6224 | LOG(INFO) << "Queuing up registration request from " << from |
| 6225 | << " because authentication is still in progress"; |
| 6226 | |
| 6227 | authenticating[from] |
| 6228 | .onReady(defer(self(), |
| 6229 | &Self::registerSlave, |
| 6230 | from, |
| 6231 | std::move(registerSlaveMessage))); |
| 6232 | return; |
| 6233 | } |
| 6234 | |
| 6235 | if (flags.authenticate_agents && !authenticated.contains(from)) { |
| 6236 | // This could happen if another authentication request came |
| 6237 | // through before we are here or if a slave tried to register |
| 6238 | // without authentication. |
| 6239 | LOG(WARNING) << "Refusing registration of agent at " << from |
| 6240 | << " because it is not authenticated"; |
| 6241 | return; |
| 6242 | } |
| 6243 | |
| 6244 | Option<Error> error = |
| 6245 | validation::master::message::registerSlave(registerSlaveMessage); |
| 6246 | |
| 6247 | if (error.isSome()) { |
| 6248 | LOG(WARNING) << "Dropping registration of agent at " << from |
| 6249 | << " because it sent an invalid registration: " |
| 6250 | << error->message; |
| 6251 | |
| 6252 | return; |
| 6253 | } |
| 6254 | |
| 6255 | if (slaves.registering.contains(from)) { |
| 6256 | LOG(INFO) << "Ignoring register agent message from " << from |
| 6257 | << " (" << registerSlaveMessage.slave().hostname() |
| 6258 | << ") as registration is already in progress"; |
| 6259 | |
| 6260 | return; |
| 6261 | } |
| 6262 | |
| 6263 | LOG(INFO) << "Received register agent message from " << from |
| 6264 | << " (" << registerSlaveMessage.slave().hostname() << ")"; |
| 6265 | |
| 6266 | slaves.registering.insert(from); |
| 6267 | |
| 6268 | // Update all resources passed by the agent to `POST_RESERVATION_REFINEMENT` |
| 6269 | // format. We do this as early as possible so that we only use a single |
| 6270 | // format inside master, and downgrade again if necessary when they leave the |
| 6271 | // master (e.g. when writing to the registry). |
| 6272 | upgradeResources(®isterSlaveMessage); |
| 6273 | |
| 6274 | // Note that the principal may be empty if authentication is not |
nothing calls this directly
no test coverage detected