From b509b07951437d4f33b814cc639a5aa9748397b2 Mon Sep 17 00:00:00 2001 From: Sergey Kraynev Date: Mon, 1 Apr 2024 17:37:45 +0400 Subject: [PATCH] Handle empty delay on update healthmonitor Check that delay field is not UnsetType before further validation Closes-Bug: #2059894 Change-Id: Ia853d43dc273019c76da09104f31aa7e1b154fec (cherry picked from commit 824b51a1dad80292b7a8ad5d61bf3ce706b1fb29) --- octavia/api/v2/controllers/health_monitor.py | 4 +++- .../functional/api/v2/test_health_monitor.py | 18 ++++++++++++++++++ ...-update-without-delay-c56240e59e15483f.yaml | 4 ++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/Fix-UDP-Health-monitor-update-without-delay-c56240e59e15483f.yaml diff --git a/octavia/api/v2/controllers/health_monitor.py b/octavia/api/v2/controllers/health_monitor.py index 9969e12263..a317c21d51 100644 --- a/octavia/api/v2/controllers/health_monitor.py +++ b/octavia/api/v2/controllers/health_monitor.py @@ -188,7 +188,9 @@ class HealthMonitorController(base.BaseController): request.type == consts.HEALTH_MONITOR_UDP_CONNECT) conf_min_delay = ( CONF.api_settings.udp_connect_min_interval_health_monitor) - if hm_is_type_udp and request.delay < conf_min_delay: + if (hm_is_type_udp and + not isinstance(request.delay, wtypes.UnsetType) and + request.delay < conf_min_delay): raise exceptions.ValidationException(detail=_( "The request delay value %(delay)s should be larger than " "%(conf_min_delay)s for %(type)s health monitor type.") % { diff --git a/octavia/tests/functional/api/v2/test_health_monitor.py b/octavia/tests/functional/api/v2/test_health_monitor.py index 62633dfba6..68a662d9f8 100644 --- a/octavia/tests/functional/api/v2/test_health_monitor.py +++ b/octavia/tests/functional/api/v2/test_health_monitor.py @@ -1782,6 +1782,24 @@ class TestHealthMonitor(base.BaseAPITest): pool_prov_status=constants.PENDING_UPDATE, hm_prov_status=constants.PENDING_UPDATE) + def test_update_udp_case_with_udp_hm(self): + api_hm = self.create_health_monitor( + self.udp_pool_with_listener_id, + constants.HEALTH_MONITOR_UDP_CONNECT, 3, 1, 1, 1).get( + self.root_tag) + self.set_lb_status(self.udp_lb_id) + new_hm = {'timeout': 2} + self.put( + self.HM_PATH.format(healthmonitor_id=api_hm.get('id')), + self._build_body(new_hm)) + self.assert_correct_status( + lb_id=self.udp_lb_id, listener_id=self.udp_listener_id, + pool_id=self.udp_pool_with_listener_id, hm_id=api_hm.get('id'), + lb_prov_status=constants.PENDING_UPDATE, + listener_prov_status=constants.PENDING_UPDATE, + pool_prov_status=constants.PENDING_UPDATE, + hm_prov_status=constants.PENDING_UPDATE) + def test_negative_update_udp_case(self): api_hm = self.create_health_monitor( self.udp_pool_with_listener_id, diff --git a/releasenotes/notes/Fix-UDP-Health-monitor-update-without-delay-c56240e59e15483f.yaml b/releasenotes/notes/Fix-UDP-Health-monitor-update-without-delay-c56240e59e15483f.yaml new file mode 100644 index 0000000000..40c7450492 --- /dev/null +++ b/releasenotes/notes/Fix-UDP-Health-monitor-update-without-delay-c56240e59e15483f.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Fixed error on update UDP Health Monitor with empty "delay" parameter