| 1773 | |
| 1774 | |
| 1775 | Try<Nothing, StatusError> TestCSIPlugin::nodeUnpublishVolume( |
| 1776 | const string& volumeId, const string& targetPath) |
| 1777 | { |
| 1778 | if (!volumes.contains(volumeId)) { |
| 1779 | return StatusError(Status( |
| 1780 | grpc::NOT_FOUND, "Volume '" + volumeId + "' does not exist")); |
| 1781 | } |
| 1782 | |
| 1783 | Try<internal::fs::MountInfoTable> table = |
| 1784 | internal::fs::MountInfoTable::read(); |
| 1785 | |
| 1786 | if (table.isError()) { |
| 1787 | return StatusError(Status( |
| 1788 | grpc::INTERNAL, "Failed to get mount table: " + table.error())); |
| 1789 | } |
| 1790 | |
| 1791 | if (std::none_of( |
| 1792 | table->entries.begin(), |
| 1793 | table->entries.end(), |
| 1794 | [&](const internal::fs::MountInfoTable::Entry& entry) { |
| 1795 | return entry.target == targetPath; |
| 1796 | })) { |
| 1797 | return Nothing(); |
| 1798 | } |
| 1799 | |
| 1800 | Try<Nothing> unmount = internal::fs::unmount(targetPath); |
| 1801 | if (unmount.isError()) { |
| 1802 | return StatusError(Status( |
| 1803 | grpc::INTERNAL, |
| 1804 | "Failed to unmount '" + targetPath + "': " + unmount.error())); |
| 1805 | } |
| 1806 | |
| 1807 | return Nothing(); |
| 1808 | } |
| 1809 | |
| 1810 | |
| 1811 | // Serves CSI calls from the given endpoint through forwarding the calls to |