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

Method start

src/slave/csi_server.cpp:299–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297
298
299Future<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(

Callers

nothing calls this directly

Calls 15

NothingClass · 0.85
deferFunction · 0.85
validateSecretFunction · 0.85
FailureClass · 0.85
typeMethod · 0.80
dataMethod · 0.80
associateMethod · 0.80
errorMethod · 0.65
stringifyFunction · 0.50
dispatchFunction · 0.50
isSomeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected