This is an automated email from the ASF dual-hosted git repository. chhsiao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit dff1eac2e0d7485181b49d4ee93e50ac6ba83e63 Author: Chun-Hung Hsiao <[email protected]> AuthorDate: Fri Apr 12 14:43:09 2019 -0700 Fixed crash when recovering a volume failed to publish with CSI v1. The CSI v1 volume manager falsely assumed that the target path always exists when unpublishing a volume, which is not true if there is a failure when publishing the volume. Review: https://reviews.apache.org/r/70468 --- src/csi/v1_volume_manager.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/csi/v1_volume_manager.cpp b/src/csi/v1_volume_manager.cpp index bf640f9..e7e0329 100644 --- a/src/csi/v1_volume_manager.cpp +++ b/src/csi/v1_volume_manager.cpp @@ -975,7 +975,12 @@ Future<Nothing> VolumeManagerProcess::_publishVolume(const string& volumeId) } return call(NODE_SERVICE, &Client::nodePublishVolume, std::move(request)) - .then(defer(self(), [this, volumeId, targetPath] { + .then(process::defer(self(), [this, volumeId, targetPath]() + -> Future<Nothing> { + if (!os::exists(targetPath)) { + return Failure("Target path '" + targetPath + "' not created"); + } + CHECK(volumes.contains(volumeId)); VolumeState& volumeState = volumes.at(volumeId).state; @@ -1158,8 +1163,6 @@ Future<Nothing> VolumeManagerProcess::__unpublishVolume(const string& volumeId) const string targetPath = paths::getMountTargetPath( paths::getMountRootDir(rootDir, info.type(), info.name()), volumeId); - CHECK(os::exists(targetPath)); - LOG(INFO) << "Calling '/csi.v1.Node/NodeUnpublishVolume' for volume '" << volumeId << "'"; @@ -1168,7 +1171,12 @@ Future<Nothing> VolumeManagerProcess::__unpublishVolume(const string& volumeId) request.set_target_path(targetPath); return call(NODE_SERVICE, &Client::nodeUnpublishVolume, std::move(request)) - .then(process::defer(self(), [this, volumeId] { + .then(process::defer(self(), [this, volumeId, targetPath]() + -> Future<Nothing> { + if (os::exists(targetPath)) { + return Failure("Target path '" + targetPath + "' not removed"); + } + CHECK(volumes.contains(volumeId)); VolumeState& volumeState = volumes.at(volumeId).state; volumeState.set_state(VolumeState::VOL_READY);
