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

Method validateVolume

src/csi/v1_volume_manager.cpp:336–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334
335
336Future<Option<Error>> VolumeManagerProcess::validateVolume(
337 const VolumeInfo& volumeInfo,
338 const CSIVolume::VolumeCapability& capability,
339 const Map<string, string>& parameters)
340{
341 // If the volume has been checkpointed, the validation succeeds only if the
342 // capability and parameters of the specified profile are the same as those in
343 // the checkpoint.
344 if (volumes.contains(volumeInfo.id)) {
345 const VolumeState& volumeState = volumes.at(volumeInfo.id).state;
346
347 if (volumeState.volume_capability() != capability) {
348 return Some(Error(
349 "Unsupported volume capability for volume '" + volumeInfo.id + "'"));
350 }
351
352 if (volumeState.parameters() != parameters) {
353 return Some(Error(
354 "Mismatched parameters for volume '" + volumeInfo.id + "'"));
355 }
356
357 return None();
358 }
359
360 LOG(INFO) << "Validating volume '" << volumeInfo.id << "'";
361
362 ValidateVolumeCapabilitiesRequest request;
363 request.set_volume_id(volumeInfo.id);
364 *request.add_volume_capabilities() = evolve(capability);
365 *request.mutable_volume_context() = volumeInfo.context;
366 *request.mutable_parameters() = parameters;
367
368 return call(
369 CONTROLLER_SERVICE,
370 &Client::validateVolumeCapabilities,
371 std::move(request))
372 .then(process::defer(self(), [=](
373 const ValidateVolumeCapabilitiesResponse& response)
374 -> Future<Option<Error>> {
375 if (!response.has_confirmed()) {
376 return Error(
377 "Validation failed for volume '" + volumeInfo.id + "': " +
378 response.message());
379 }
380
381 if (response.confirmed().volume_context() != volumeInfo.context) {
382 return Error(
383 "Validation failed for volume '" + volumeInfo.id +
384 "': Mismatched volume context");
385 }
386
387 if (std::none_of(
388 response.confirmed().volume_capabilities().begin(),
389 response.confirmed().volume_capabilities().end(),
390 [&](const csi::v1::VolumeCapability& _capability) {
391 return csi::v1::devolve(_capability) == capability;
392 })) {
393 return Error(

Callers 1

applyCreateDiskMethod · 0.45

Calls 15

SomeFunction · 0.85
NoneClass · 0.85
deferFunction · 0.85
FailureClass · 0.85
atMethod · 0.80
evolveFunction · 0.70
devolveFunction · 0.70
ErrorFunction · 0.50
containsMethod · 0.45
parametersMethod · 0.45
thenMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected