Commit b57ee44
committed
api: Avoid race-condition in volume-attach timeout handling
When nova-api calls reserve_block_device_name RPC to nova-compute and
the call times out, we try to clean up by deleting the BDM entry. However,
during the timeout window a second attachment request for the same volume
can come in, create a valid BDM, and progress to talking to Cinder.
The original timed-out request then deletes this new valid BDM, leaving
the volume in an inconsistent state.
We fix this by checking if the BDM has attachment_id set before
deleting it. The attachment_id field is only populated in
_check_attach_and_reserve_volume(), which we only call after the
reserve_block_device_name RPC succeeds. If attachment_id is set,
we know the BDM belongs to a subsequent request that has already
progressed past the RPC phase, so we should not delete it.
Change-Id: I7ed649a5cab7f254690f329fac285128d8cd1c921 parent ba48137 commit b57ee44
2 files changed
+60
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5145 | 5145 | | |
5146 | 5146 | | |
5147 | 5147 | | |
| 5148 | + | |
| 5149 | + | |
| 5150 | + | |
| 5151 | + | |
5148 | 5152 | | |
5149 | 5153 | | |
5150 | | - | |
5151 | | - | |
5152 | | - | |
5153 | | - | |
| 5154 | + | |
| 5155 | + | |
| 5156 | + | |
| 5157 | + | |
| 5158 | + | |
| 5159 | + | |
| 5160 | + | |
| 5161 | + | |
| 5162 | + | |
| 5163 | + | |
| 5164 | + | |
| 5165 | + | |
| 5166 | + | |
5154 | 5167 | | |
5155 | 5168 | | |
5156 | 5169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
| 540 | + | |
| 541 | + | |
540 | 542 | | |
541 | 543 | | |
542 | 544 | | |
| |||
556 | 558 | | |
557 | 559 | | |
558 | 560 | | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
559 | 602 | | |
560 | 603 | | |
561 | 604 | | |
| |||
0 commit comments