From bfac0145e6dd86a3b4a3534c5b98786a027a5462 Mon Sep 17 00:00:00 2001 From: Gregory Thiemonge Date: Wed, 7 Apr 2021 11:36:15 +0200 Subject: [PATCH] Fix updating a non-HTTP(S) Health Monitor Prevent octavia-dashboard from sending parameters that trigger a InvalidOption exception when updating a non-HTTP/non-HTTPS health monitor. Story 2008803 Task 42223 Change-Id: Ie669829b149001f77f7475216b86a33d96cb5ff5 (cherry picked from commit a8dc94fdbd4b46b16d77a2cd63931ee4078e48f9) --- octavia_dashboard/api/rest/lbaasv2.py | 26 ++++++++++++------- ...updating-non-http-hm-114180139961e441.yaml | 5 ++++ 2 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/fix-updating-non-http-hm-114180139961e441.yaml diff --git a/octavia_dashboard/api/rest/lbaasv2.py b/octavia_dashboard/api/rest/lbaasv2.py index e3113022..b16833c2 100644 --- a/octavia_dashboard/api/rest/lbaasv2.py +++ b/octavia_dashboard/api/rest/lbaasv2.py @@ -556,19 +556,27 @@ def update_monitor(request, **kwargs): """ data = request.DATA monitor_id = data['monitor']['id'] + hm_type = data['monitor']['type'] conn = _get_sdk_connection(request) + healthmonitor_kwargs = { + 'delay': data['monitor'].get('delay'), + 'timeout': data['monitor'].get('timeout'), + 'max_retries': data['monitor'].get('max_retries'), + 'max_retries_down': data['monitor'].get('max_retries_down'), + 'admin_state_up': data['monitor'].get('admin_state_up'), + 'name': data['monitor'].get('name') + } + if hm_type in ('HTTP', 'HTTPS'): + healthmonitor_kwargs.update({ + 'http_method': data['monitor'].get('http_method'), + 'url_path': data['monitor'].get('url_path'), + 'expected_codes': data['monitor'].get('expected_codes') + }) + healthmonitor = conn.load_balancer.update_health_monitor( monitor_id, - delay=data['monitor'].get('delay'), - timeout=data['monitor'].get('timeout'), - max_retries=data['monitor'].get('max_retries'), - max_retries_down=data['monitor'].get('max_retries_down'), - http_method=data['monitor'].get('http_method'), - url_path=data['monitor'].get('url_path'), - expected_codes=data['monitor'].get('expected_codes'), - admin_state_up=data['monitor'].get('admin_state_up'), - name=data['monitor'].get('name') + **healthmonitor_kwargs ) return _get_sdk_object_dict(healthmonitor) diff --git a/releasenotes/notes/fix-updating-non-http-hm-114180139961e441.yaml b/releasenotes/notes/fix-updating-non-http-hm-114180139961e441.yaml new file mode 100644 index 00000000..ed1403cb --- /dev/null +++ b/releasenotes/notes/fix-updating-non-http-hm-114180139961e441.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fix a bug that prevented the update of non-HTTP and non-HTTPS health + monitors.