| 297 | |
| 298 | |
| 299 | Future<Nothing> CSIServerProcess::start(const SlaveID& _agentId) |
| 300 | { |
| 301 | // NOTE: It's possible that the agent receives multiple |
| 302 | // `SlaveRegisteredMessage`s and detects a disconnection in between. |
| 303 | // In that case, `start` will be called multiple times from |
| 304 | // `Slave::registered`. |
| 305 | if (agentId.isSome()) { |
| 306 | CHECK_EQ(agentId.get(), _agentId) |
| 307 | << "Cannot start CSI server with agent ID " << _agentId |
| 308 | << " (expected: " << agentId.get() << ")"; |
| 309 | |
| 310 | return Nothing(); |
| 311 | } |
| 312 | |
| 313 | agentId = _agentId; |
| 314 | |
| 315 | Future<Nothing> result = Nothing(); |
| 316 | |
| 317 | if (secretGenerator) { |
| 318 | // The contents of this principal are arbitrary. We choose to avoid a |
| 319 | // principal with a 'value' string so that we do not unintentionally collide |
| 320 | // with another real principal with restricted permissions. |
| 321 | Principal principal( |
| 322 | Option<string>::none(), |
| 323 | {{"cid_prefix", DEFAULT_CSI_CONTAINER_PREFIX}}); |
| 324 | |
| 325 | result = secretGenerator->generate(principal) |
| 326 | .then(defer(self(), [=](const Secret& secret) -> Future<Nothing> { |
| 327 | Option<Error> error = common::validation::validateSecret(secret); |
| 328 | if (error.isSome()) { |
| 329 | return Failure( |
| 330 | "CSI server failed to validate generated secret: " + |
| 331 | error->message); |
| 332 | } |
| 333 | |
| 334 | if (secret.type() != Secret::VALUE) { |
| 335 | return Failure( |
| 336 | "CSI server expecting generated secret to be of VALUE type " |
| 337 | "instead of " + stringify(secret.type()) + " type; " + |
| 338 | "only VALUE type secrets are supported at this time"); |
| 339 | } |
| 340 | |
| 341 | CHECK(secret.has_value()); |
| 342 | |
| 343 | authToken = secret.value().data(); |
| 344 | |
| 345 | return Nothing(); |
| 346 | })); |
| 347 | } |
| 348 | |
| 349 | return result |
| 350 | .then(defer(self(), [=]() -> Future<Nothing> { |
| 351 | // Load all CSI plugin configurations found. |
| 352 | // NOTE: `initializePlugin()` requires that the `authToken` has already |
| 353 | // been set, so the order of these continuations matters. |
| 354 | Try<Nothing> init = initializePlugin(); |
| 355 | if (init.isError()) { |
| 356 | return Failure( |
nothing calls this directly
no test coverage detected