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

Function foreach

src/csi/v0_volume_manager.cpp:130–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128 vector<Future<Nothing>> futures;
129
130 foreach (const string& path, volumePaths.get()) {
131 Try<paths::VolumePath> volumePath =
132 paths::parseVolumePath(rootDir, path);
133
134 if (volumePath.isError()) {
135 return Failure(
136 "Failed to parse volume path '" + path +
137 "': " + volumePath.error());
138 }
139
140 CHECK_EQ(info.type(), volumePath->type);
141 CHECK_EQ(info.name(), volumePath->name);
142
143 const string& volumeId = volumePath->volumeId;
144 const string statePath = paths::getVolumeStatePath(
145 rootDir, info.type(), info.name(), volumeId);
146
147 if (!os::exists(statePath)) {
148 continue;
149 }
150
151 Result<VolumeState> volumeState =
152 slave::state::read<VolumeState>(statePath);
153
154 if (volumeState.isError()) {
155 return Failure(
156 "Failed to read volume state from '" + statePath +
157 "': " + volumeState.error());
158 }
159
160 if (volumeState.isNone()) {
161 continue;
162 }
163
164 volumes.put(volumeId, std::move(volumeState.get()));
165 VolumeData& volume = volumes.at(volumeId);
166
167 if (!VolumeState::State_IsValid(volume.state.state())) {
168 return Failure("Volume '" + volumeId + "' is in INVALID state");
169 }
170
171 // First, if there is a node reboot after the volume is made
172 // publishable, it should be reset to `NODE_READY`.
173 switch (volume.state.state()) {
174 case VolumeState::CREATED:
175 case VolumeState::NODE_READY:
176 case VolumeState::CONTROLLER_PUBLISH:
177 case VolumeState::CONTROLLER_UNPUBLISH:
178 case VolumeState::NODE_STAGE: {
179 break;
180 }
181 case VolumeState::VOL_READY:
182 case VolumeState::PUBLISHED:
183 case VolumeState::NODE_UNSTAGE:
184 case VolumeState::NODE_PUBLISH:
185 case VolumeState::NODE_UNPUBLISH: {
186 if (bootId != volume.state.boot_id()) {
187 // Since this is a no-op, no need to checkpoint here.

Callers

nothing calls this directly

Calls 15

parseVolumePathFunction · 0.85
FailureClass · 0.85
getVolumeStatePathFunction · 0.85
parseMountPathFunction · 0.85
BytesClass · 0.85
typeMethod · 0.80
atMethod · 0.80
errorMethod · 0.65
existsFunction · 0.50
stringifyFunction · 0.50
isErrorMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected