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

Function foreach

src/csi/v1_volume_manager.cpp:131–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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()));
166 VolumeData& volume = volumes.at(volumeId);
167
168 if (!VolumeState::State_IsValid(volume.state.state())) {
169 return Failure("Volume '" + volumeId + "' is in INVALID state");
170 }
171
172 // First, if there is a node reboot after the volume is made
173 // publishable, it should be reset to `NODE_READY`.
174 switch (volume.state.state()) {
175 case VolumeState::CREATED:
176 case VolumeState::NODE_READY:
177 case VolumeState::CONTROLLER_PUBLISH:
178 case VolumeState::CONTROLLER_UNPUBLISH:
179 case VolumeState::NODE_STAGE: {
180 break;
181 }
182 case VolumeState::VOL_READY:
183 case VolumeState::PUBLISHED:
184 case VolumeState::NODE_UNSTAGE:
185 case VolumeState::NODE_PUBLISH:
186 case VolumeState::NODE_UNPUBLISH: {
187 if (bootId != volume.state.boot_id()) {
188 // 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