| 218 | } |
| 219 | |
| 220 | foreachpair (const string& _name, const CSIPluginInfo& info, pluginConfigs) { |
| 221 | // Default-construct the plugin struct so that we have a valid runtime |
| 222 | // to pass into the service manager. |
| 223 | plugins.put(_name, CSIPlugin(info, "csi_plugins/" + _name + "/")); |
| 224 | |
| 225 | CSIPlugin& plugin = plugins.at(_name); |
| 226 | |
| 227 | if (info.containers_size() > 0) { |
| 228 | CHECK_SOME(agentId); |
| 229 | |
| 230 | plugin.serviceManager.reset(new ServiceManager( |
| 231 | agentId.get(), |
| 232 | agentUrl, |
| 233 | rootDir, |
| 234 | info, |
| 235 | extractServices(info), |
| 236 | DEFAULT_CSI_CONTAINER_PREFIX, |
| 237 | authToken, |
| 238 | plugin.runtime, |
| 239 | &plugin.metrics)); |
| 240 | } else { |
| 241 | CHECK(info.endpoints_size() > 0); |
| 242 | |
| 243 | plugin.serviceManager.reset(new ServiceManager( |
| 244 | info, |
| 245 | extractServices(info), |
| 246 | plugin.runtime, |
| 247 | &plugin.metrics)); |
| 248 | } |
| 249 | |
| 250 | plugin.initialized.associate( |
| 251 | plugin.serviceManager->recover() |
| 252 | .then(defer(self(), [=]() { |
| 253 | CHECK(plugins.contains(_name)); |
| 254 | |
| 255 | return plugins.at(_name).serviceManager->getApiVersion(); |
| 256 | })) |
| 257 | .then(defer(self(), [=](const string& apiVersion) -> Future<Nothing> { |
| 258 | CHECK(plugins.contains(_name)); |
| 259 | |
| 260 | Try<Owned<VolumeManager>> volumeManager = VolumeManager::create( |
| 261 | rootDir, |
| 262 | info, |
| 263 | extractServices(info), |
| 264 | apiVersion, |
| 265 | plugins.at(_name).runtime, |
| 266 | plugins.at(_name).serviceManager.get(), |
| 267 | &plugins.at(_name).metrics, |
| 268 | secretResolver); |
| 269 | |
| 270 | if (volumeManager.isError()) { |
| 271 | return Failure( |
| 272 | "CSI server failed to create volume manager for plugin" |
| 273 | " '" + info.name() + "': " + volumeManager.error()); |
| 274 | } |
| 275 | |
| 276 | plugins.at(_name).volumeManager = std::move(volumeManager.get()); |
| 277 |
nothing calls this directly
no test coverage detected