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
This commit is contained in:
Gregory Thiemonge 2021-04-07 11:36:15 +02:00
parent 7fb4bac2e8
commit a8dc94fdbd
2 changed files with 22 additions and 9 deletions

View File

@ -568,19 +568,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)

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fix a bug that prevented the update of non-HTTP and non-HTTPS health
monitors.