Commit 913eb59
authored
fix: track created disks in the state file so an interrupt cannot orphan them (#160)
Standalone disks were recorded in an instance variable, and the cleanup
that deletes them hangs off `rescue => e`, which catches StandardError.
Interrupt is not a StandardError, so Ctrl-C during a create -- the most
common way a create ends early -- skipped cleanup entirely and left a
billable disk behind with no record of it anywhere:
disks: tk-datadisk-...-extra-disk 20GB (no users)
state: --- {}
kitchen destroy -> Finished destroying (0m0.00s)
Record the disks in the Test Kitchen state file instead, which is written
whatever happens, and have `destroy` delete anything still recorded once
the instance is gone. This mirrors what the instance itself already does.
Two supporting changes are needed to make that reachable:
- Pin the zone before any billable resource exists. In region mode it is
chosen at random, so cleanup would not otherwise know where to look.
- Record the server name before the insert request is issued rather than
after it returns. Live testing turned up a case where GCE created the
instance but the interrupted request never returned, so the state file
had the disk but not the instance holding it, and cleanup failed with
resourceInUseByAnotherResource.
Confirmed against a real project: an interrupted create is now fully
reclaimed by `kitchen destroy`, leaving no instances and no disks.1 parent d353a02 commit 913eb59
2 files changed
Lines changed: 117 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
200 | 213 | | |
201 | 214 | | |
202 | 215 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | 216 | | |
211 | 217 | | |
212 | 218 | | |
| |||
231 | 237 | | |
232 | 238 | | |
233 | 239 | | |
234 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
235 | 248 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
241 | 252 | | |
242 | 253 | | |
243 | | - | |
| 254 | + | |
244 | 255 | | |
245 | 256 | | |
246 | 257 | | |
247 | 258 | | |
248 | | - | |
249 | 259 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
256 | 268 | | |
257 | 269 | | |
| 270 | + | |
| 271 | + | |
258 | 272 | | |
259 | 273 | | |
260 | 274 | | |
| |||
1041 | 1055 | | |
1042 | 1056 | | |
1043 | 1057 | | |
1044 | | - | |
1045 | | - | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1046 | 1067 | | |
1047 | 1068 | | |
1048 | 1069 | | |
1049 | | - | |
| 1070 | + | |
1050 | 1071 | | |
1051 | 1072 | | |
1052 | | - | |
1053 | | - | |
| 1073 | + | |
| 1074 | + | |
1054 | 1075 | | |
1055 | 1076 | | |
1056 | 1077 | | |
1057 | 1078 | | |
1058 | | - | |
| 1079 | + | |
1059 | 1080 | | |
1060 | 1081 | | |
1061 | 1082 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
348 | 417 | | |
349 | 418 | | |
350 | 419 | | |
| |||
0 commit comments