Correct retry interval during attach volume

When we try to simultaneously attach same volume multiple times
(multiattach), there are multiple attachments created, suppose
attachA and attachB. If attachA marks the volume "reserved" then
attachB can't proceed until the volume is in "in-use" or "available"
state. We retry until we reach any of these states for which we use
the retrying library.

The retrying library defaults to 1 second retry[1] (5 times) which causes
the original failure as the volume takes time to transition between
"reserved" -> "in-use" state. This patch corrects it by adding an
exponential retry time and max exponential retry i.e.

1: 2 ** 1 = 2 seconds
2: 2 ** 2 = 4 seconds
3: 2 ** 3 = 8 seconds
4: 2 ** 4 = 16 seconds (but max wait time is 10 seconds)
5: 2 ** 5 = 32 seconds (but max wait time is 10 seconds)

[1] https://github.com/rholder/retrying/blob/master/retrying.py#L84

Closes-Bug: #1969373

Change-Id: I0094b044085d7f92b07ea86236de3b6efd7d67ea
This commit is contained in:
whoami-rajat 2022-04-18 21:43:14 +05:30
parent 77919e15d2
commit ba4af147fb
2 changed files with 10 additions and 1 deletions

View File

@ -71,7 +71,9 @@ class API(object):
client.volumes.delete(volume_id)
@retrying.retry(stop_max_attempt_number=5,
retry_on_exception=_retry_on_bad_request)
retry_on_exception=_retry_on_bad_request,
wait_exponential_multiplier=1000,
wait_exponential_max=10000)
@handle_exceptions
def attachment_create(self, client, volume_id, connector=None,
mountpoint=None, mode=None):

View File

@ -0,0 +1,7 @@
---
fixes:
- |
`Bug #1969373 <https://bugs.launchpad.net/glance-store/+bug/1969373>`_:
Cinder Driver: Correct the retry interval from fixed 1 second to
exponential backoff for attaching a volume during image create/save
operation.