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

Method getEndpoint

src/csi/service_manager.cpp:688–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

686
687
688Future<string> ServiceManagerProcess::getEndpoint(
689 const ContainerID& containerId)
690{
691 if (endpoints.contains(containerId)) {
692 return endpoints.at(containerId)->future();
693 }
694
695 CHECK(!daemons.contains(containerId));
696
697 Option<CSIPluginContainerInfo> config = getContainerInfo(containerId);
698 CHECK_SOME(config);
699
700 // We checkpoint the config first to keep track of the plugin container even
701 // if we fail to create its container daemon.
702 const string configPath =
703 paths::getContainerInfoPath(rootDir, info.type(), info.name(), containerId);
704
705 Try<Nothing> checkpoint = slave::state::checkpoint(configPath, config.get());
706 if (checkpoint.isError()) {
707 return Failure(
708 "Failed to checkpoint plugin container config to '" + configPath +
709 "': " + checkpoint.error());
710 }
711
712 CommandInfo commandInfo;
713
714 if (config->has_command()) {
715 commandInfo = config->command();
716 }
717
718 // Set the `CSI_ENDPOINT` environment variable.
719 Try<string> endpointPath = paths::getEndpointSocketPath(
720 rootDir, info.type(), info.name(), containerId);
721
722 if (endpointPath.isError()) {
723 return Failure(
724 "Failed to resolve endpoint path for plugin container '" +
725 stringify(containerId) + "': " + endpointPath.error());
726 }
727
728 const string endpoint = "unix://" + endpointPath.get();
729 Environment::Variable* endpoint_ =
730 commandInfo.mutable_environment()->add_variables();
731
732 endpoint_->set_name("CSI_ENDPOINT");
733 endpoint_->set_value(endpoint);
734
735 // For some CSI Plugins (like NFS CSI plugin), their node service need
736 // a node ID specified by container orchestrator, so here we expose agent
737 // ID to the plugins, they can use that as the node ID.
738 if (config->services().end() != std::find(
739 config->services().begin(),
740 config->services().end(),
741 NODE_SERVICE)) {
742 Environment::Variable* nodeId =
743 commandInfo.mutable_environment()->add_variables();
744
745 nodeId->set_name("MESOS_AGENT_ID");

Callers

nothing calls this directly

Calls 15

getContainerInfoFunction · 0.85
getContainerInfoPathFunction · 0.85
checkpointFunction · 0.85
FailureClass · 0.85
getEndpointSocketPathFunction · 0.85
findFunction · 0.85
PathClass · 0.85
getMountRootDirFunction · 0.85
deferFunction · 0.85
NothingClass · 0.85
atMethod · 0.80
typeMethod · 0.80

Tested by

no test coverage detected