Prevent failure on get quiesce_wait_time

quiesce_wait_time was an option introduced in API version 2.75. It
modified the promote API. In the current implementation, there is
a chance that we will receive a {'promote': null} request body. In
that case, and the quiesce_wait_time change was only accounting
that we would receive a dictionary.

This change prevents such failure to happen by ensuring we are
trying to get quiesce_wait_time from a dictionary.

Change-Id: I9444162a7d4e861e5f11f4d798014c7b90216952
This commit is contained in:
silvacarloss 2023-02-17 08:39:47 -03:00
parent d5792fe218
commit bb67f6ac2a
1 changed files with 5 additions and 1 deletions

View File

@ -278,7 +278,11 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin):
quiesce_wait_time = None
if allow_quiesce_wait_time:
wait_time = body.get('promote', {}).get('quiesce_wait_time')
# NOTE(carloss): there is a chance that we receive
# {'promote': null}, so we need to prevent that
promote_data = body.get('promote', {})
promote_data = {} if promote_data is None else promote_data
wait_time = promote_data.get('quiesce_wait_time')
if wait_time:
if not strutils.is_int_like(wait_time) or int(wait_time) <= 0:
msg = _("quiesce_wait_time must be an integer and "