Handle empty delay on update healthmonitor

Check that delay field is not UnsetType before further validation

Closes-Bug: #2059894
Change-Id: Ia853d43dc273019c76da09104f31aa7e1b154fec
This commit is contained in:
Sergey Kraynev 2024-04-01 17:37:45 +04:00
parent fa7cc01787
commit 824b51a1da
No known key found for this signature in database
GPG Key ID: 23F0753A8D7AA3B1
3 changed files with 25 additions and 1 deletions

View File

@ -188,7 +188,9 @@ class HealthMonitorController(base.BaseController):
request.type == consts.HEALTH_MONITOR_UDP_CONNECT) request.type == consts.HEALTH_MONITOR_UDP_CONNECT)
conf_min_delay = ( conf_min_delay = (
CONF.api_settings.udp_connect_min_interval_health_monitor) 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=_( raise exceptions.ValidationException(detail=_(
"The request delay value %(delay)s should be larger than " "The request delay value %(delay)s should be larger than "
"%(conf_min_delay)s for %(type)s health monitor type.") % { "%(conf_min_delay)s for %(type)s health monitor type.") % {

View File

@ -1782,6 +1782,24 @@ class TestHealthMonitor(base.BaseAPITest):
pool_prov_status=constants.PENDING_UPDATE, pool_prov_status=constants.PENDING_UPDATE,
hm_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): def test_negative_update_udp_case(self):
api_hm = self.create_health_monitor( api_hm = self.create_health_monitor(
self.udp_pool_with_listener_id, self.udp_pool_with_listener_id,

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Fixed error on update UDP Health Monitor with empty "delay" parameter