| 106 | |
| 107 | |
| 108 | Future<Nothing> VolumeManagerProcess::recover() |
| 109 | { |
| 110 | Try<string> bootId_ = os::bootId(); |
| 111 | if (bootId_.isError()) { |
| 112 | return Failure("Failed to get boot ID: " + bootId_.error()); |
| 113 | } |
| 114 | |
| 115 | bootId = bootId_.get(); |
| 116 | |
| 117 | return prepareServices() |
| 118 | .then(process::defer(self(), [this]() -> Future<Nothing> { |
| 119 | // Recover the states of CSI volumes. |
| 120 | Try<list<string>> volumePaths = |
| 121 | paths::getVolumePaths(rootDir, info.type(), info.name()); |
| 122 | |
| 123 | if (volumePaths.isError()) { |
| 124 | return Failure( |
| 125 | "Failed to find volumes for CSI plugin type '" + info.type() + |
| 126 | "' and name '" + info.name() + "': " + volumePaths.error()); |
| 127 | } |
| 128 | |
| 129 | vector<Future<Nothing>> futures; |
| 130 | |
| 131 | foreach (const string& path, volumePaths.get()) { |
| 132 | Try<paths::VolumePath> volumePath = |
| 133 | paths::parseVolumePath(rootDir, path); |
| 134 | |
| 135 | if (volumePath.isError()) { |
| 136 | return Failure( |
| 137 | "Failed to parse volume path '" + path + |
| 138 | "': " + volumePath.error()); |
| 139 | } |
| 140 | |
| 141 | CHECK_EQ(info.type(), volumePath->type); |
| 142 | CHECK_EQ(info.name(), volumePath->name); |
| 143 | |
| 144 | const string& volumeId = volumePath->volumeId; |
| 145 | const string statePath = paths::getVolumeStatePath( |
| 146 | rootDir, info.type(), info.name(), volumeId); |
| 147 | |
| 148 | if (!os::exists(statePath)) { |
| 149 | continue; |
| 150 | } |
| 151 | |
| 152 | Result<VolumeState> volumeState = |
| 153 | slave::state::read<VolumeState>(statePath); |
| 154 | |
| 155 | if (volumeState.isError()) { |
| 156 | return Failure( |
| 157 | "Failed to read volume state from '" + statePath + |
| 158 | "': " + volumeState.error()); |
| 159 | } |
| 160 | |
| 161 | if (volumeState.isNone()) { |
| 162 | continue; |
| 163 | } |
| 164 | |
| 165 | volumes.put(volumeId, std::move(volumeState.get())); |
nothing calls this directly
no test coverage detected