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

Method publishVolume

src/slave/csi_server.cpp:365–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363
364
365Future<string> CSIServerProcess::publishVolume(const Volume& volume)
366{
367 CHECK(volume.has_source() &&
368 volume.source().has_type() &&
369 volume.source().type() == Volume::Source::CSI_VOLUME);
370
371 CHECK(volume.source().has_csi_volume() &&
372 volume.source().csi_volume().has_static_provisioning());
373
374 const Volume::Source::CSIVolume& csiVolume = volume.source().csi_volume();
375
376 const string& name = csiVolume.plugin_name();
377
378 if (!plugins.contains(name)) {
379 // This will attempt to load the plugin's configuration, initialize the
380 // plugin, and insert it into the `plugins` map.
381 Try<Nothing> pluginInit = initializePlugin(name);
382 if (pluginInit.isError()) {
383 return Failure(
384 "Failed to initialize CSI plugin '" +
385 name + "': " + pluginInit.error());
386 }
387 }
388
389 CHECK(plugins.contains(name));
390
391 return plugins.at(name).initialized.future()
392 .then(defer(self(), [=]() {
393 CHECK(plugins.contains(name));
394
395 return plugins.at(name).volumeManager->publishVolume(
396 csiVolume.static_provisioning().volume_id(),
397 createVolumeState(volume));
398 }))
399 .then(defer(self(), [=]() {
400 CHECK(plugins.contains(name));
401
402 const CSIPluginInfo& info = plugins.at(csiVolume.plugin_name()).info;
403
404 const string mountRootDir = info.has_target_path_root()
405 ? info.target_path_root()
406 : csi::paths::getMountRootDir(rootDir, info.type(), info.name());
407
408 return csi::paths::getMountTargetPath(
409 mountRootDir,
410 csiVolume.static_provisioning().volume_id());
411 }));
412}
413
414
415Future<Nothing> CSIServerProcess::unpublishVolume(

Callers 3

foreachFunction · 0.45
TEST_PFunction · 0.45
foreachFunction · 0.45

Calls 14

FailureClass · 0.85
deferFunction · 0.85
createVolumeStateFunction · 0.85
getMountRootDirFunction · 0.85
getMountTargetPathFunction · 0.85
typeMethod · 0.80
atMethod · 0.80
errorMethod · 0.65
containsMethod · 0.45
isErrorMethod · 0.45
thenMethod · 0.45
futureMethod · 0.45

Tested by 1

TEST_PFunction · 0.36