Commit ab9fcc2
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 ab9fcc2
2 files changed
+60
-5
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 | + | |
5154 | 5166 | | |
5155 | 5167 | | |
5156 | 5168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
540 | 582 | | |
541 | 583 | | |
542 | 584 | | |
| |||
554 | 596 | | |
555 | 597 | | |
556 | 598 | | |
557 | | - | |
| 599 | + | |
| 600 | + | |
558 | 601 | | |
559 | 602 | | |
560 | 603 | | |
| |||
0 commit comments