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

Method recover

src/csi/v1_volume_manager.cpp:108–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106
107
108Future<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()));

Callers

nothing calls this directly

Calls 13

FailureClass · 0.85
deferFunction · 0.85
getVolumePathsFunction · 0.85
getMountPathsFunction · 0.85
collectFunction · 0.85
NothingClass · 0.85
typeMethod · 0.80
errorMethod · 0.65
bootIdFunction · 0.50
isErrorMethod · 0.45
getMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected