diff --git a/ovn_octavia_provider/helper.py b/ovn_octavia_provider/helper.py index adbbfc35..a25f709f 100644 --- a/ovn_octavia_provider/helper.py +++ b/ovn_octavia_provider/helper.py @@ -2472,11 +2472,15 @@ class OvnProviderHelper(): LOG.debug("Could not find LB with pool id %s", pool_id) return status - options = { - 'interval': str(info['interval']), - 'timeout': str(info['timeout']), - 'success_count': str(info['success_count']), - 'failure_count': str(info['failure_count'])} + options = {} + if info['interval']: + options['interval'] = str(info['interval']) + if info['timeout']: + options['timeout'] = str(info['timeout']) + if info['success_count']: + options['success_count'] = str(info['success_count']) + if info['failure_count']: + options['failure_count'] = str(info['failure_count']) commands = [] commands.append( diff --git a/ovn_octavia_provider/tests/unit/test_helper.py b/ovn_octavia_provider/tests/unit/test_helper.py index 8ee5efae..6afab779 100644 --- a/ovn_octavia_provider/tests/unit/test_helper.py +++ b/ovn_octavia_provider/tests/unit/test_helper.py @@ -3675,6 +3675,21 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase): self.assertEqual(status['healthmonitors'][0]['operating_status'], constants.ERROR) + @mock.patch.object(ovn_helper.OvnProviderHelper, '_find_ovn_lb_from_hm_id') + def test_hm_update_just_interval(self, folbfhi): + folbfhi.return_value = (self.ovn_hm, self.ovn_hm_lb) + self.health_monitor['interval'] = 3 + self.helper.hm_update(self.health_monitor) + options = { + 'interval': str(self.health_monitor['interval']), + 'timeout': str(self.health_monitor['timeout']), + 'success_count': str(self.health_monitor['success_count']), + 'failure_count': str(self.health_monitor['failure_count'])} + self.helper.ovn_nbdb_api.db_set.assert_called_once_with( + 'Load_Balancer_Health_Check', + self.ovn_hm.uuid, + ('options', options)) + def test_hm_delete(self): self.helper.ovn_nbdb_api.db_list_rows.return_value.\ execute.return_value = [self.ovn_hm]