From bb67f6ac2a1c213c76957328db339d4454628c50 Mon Sep 17 00:00:00 2001 From: silvacarloss Date: Fri, 17 Feb 2023 08:39:47 -0300 Subject: [PATCH] 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 --- manila/api/v2/share_replicas.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manila/api/v2/share_replicas.py b/manila/api/v2/share_replicas.py index 71e5a42e03..b5aabf2a9e 100644 --- a/manila/api/v2/share_replicas.py +++ b/manila/api/v2/share_replicas.py @@ -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 "