Commit 061e4ce
committed
cinder csi: validate volume status and migration_status before attach
Check that a volume is in an acceptable state before calling the Nova
attach API:
- For regular (single-attach) volumes: status must be 'available'
- For multi-attach capable volumes: status must be 'available' or 'in-use'
- migration_status must not be 'migrating'
Previously the driver would blindly call volumeattach.Create regardless
of volume status, relying on Nova/Cinder to reject the request. This
produced opaque errors that made troubleshooting difficult and generated
unnecessary API calls for volumes in transitional states (creating,
downloading, detaching, etc.).
The migration_status check prevents attempting to attach a volume that is
actively being migrated, which would fail with an opaque error from Cinder.
A custom volumeForAttach struct is used to extract migration_status from
the Cinder API response, since gophercloud's Volume struct does not map
this field.
With this change the driver returns immediate, descriptive errors when
the volume is not attachable, allowing the CO (external-attacher) to
retry with exponential backoff via standard CSI error handling.1 parent d1cc4cb commit 061e4ce
2 files changed
Lines changed: 505 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
205 | 215 | | |
206 | 216 | | |
207 | 217 | | |
208 | 218 | | |
209 | | - | |
210 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
211 | 225 | | |
212 | 226 | | |
213 | 227 | | |
214 | | - | |
| 228 | + | |
215 | 229 | | |
216 | 230 | | |
217 | | - | |
| 231 | + | |
218 | 232 | | |
219 | 233 | | |
220 | 234 | | |
221 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
222 | 249 | | |
223 | 250 | | |
224 | 251 | | |
225 | 252 | | |
226 | 253 | | |
227 | 254 | | |
228 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
229 | 260 | | |
230 | 261 | | |
231 | | - | |
| 262 | + | |
232 | 263 | | |
233 | | - | |
| 264 | + | |
234 | 265 | | |
235 | 266 | | |
236 | | - | |
| 267 | + | |
237 | 268 | | |
238 | 269 | | |
239 | 270 | | |
240 | | - | |
| 271 | + | |
241 | 272 | | |
242 | 273 | | |
243 | 274 | | |
| |||
0 commit comments