Replace LOG.warn

The warn method is deprecated in favor of the warning method.

Also fix a few more errors now complained by hacking checks from
neutron-lib.

Note that N530 in test code are silenced for now, due to some amount
of change we may need but want to avoid right before RC release.

Change-Id: I051a1b9d003a5501bc50f27dd9efb0cd5797ed95
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami
2025-06-22 22:39:21 +09:00
parent 5895ae7c4e
commit 02ae2489a0
10 changed files with 29 additions and 29 deletions

View File

@@ -823,7 +823,7 @@ class OvnProviderDriver(driver_base.ProviderDriver):
if fips:
neutron_fip = fips[0].floating_ip_address
if not vip_lsp:
LOG.warn(
LOG.warning(
"Logic Switch Port not found for port "
f"{loadbalancer.vip_port_id}. "
"Skip sync FIP for loadbalancer "
@@ -832,7 +832,7 @@ class OvnProviderDriver(driver_base.ProviderDriver):
"first to sync OVN DB with Neutron DB.")
return
if lsp_fip != neutron_fip:
LOG.warn(
LOG.warning(
"Floating IP not consistent between Logic Switch "
f"Port and Neutron. Found FIP {lsp_fip} "
f"in LSP {vip_lsp.name}, but we have {neutron_fip} from "
@@ -845,10 +845,10 @@ class OvnProviderDriver(driver_base.ProviderDriver):
vip_lp=vip_lsp, fip=lsp_fip,
action=ovn_const.REQ_INFO_ACTION_SYNC)
else:
LOG.warn("Floating IP not found for loadbalancer "
f"{loadbalancer.loadbalancer_id}")
LOG.warning("Floating IP not found for loadbalancer "
f"{loadbalancer.loadbalancer_id}")
if lsp_fip:
LOG.warn(
LOG.warning(
"Floating IP not consistent between Logic Switch "
f"Port and Neutron. Found FIP {lsp_fip} configured "
f"in LSP {vip_lsp.name}, but no FIP configured from "

View File

@@ -42,7 +42,7 @@ tests_imports_from2 = re.compile(
r"\bfrom[\s]+ovn_octavia_provider[\s]+import[\s]+tests\b")
no_line_continuation_backslash_re = re.compile(r'.*(\\)\n')
import_mock = re.compile(r"\bimport[\s]+mock\b") # noqa: H216
import_mock = re.compile(r"\bimport[\s]+mock\b") # noqa :H216
import_from_mock = re.compile(r"\bfrom[\s]+mock[\s]+import\b")

View File

@@ -467,7 +467,7 @@ class OvnProviderHelper():
try:
return clients.get_neutron_client()
except driver_exceptions.DriverError as e:
LOG.warn(f"Cannot get client from neutron {e}")
LOG.warning(f"Cannot get client from neutron {e}")
return None
def _get_vip_port_and_subnet_from_lb(self, neutron_client, vip_port_id,
@@ -482,10 +482,10 @@ class OvnProviderHelper():
subnet_requested
)
except openstack.exceptions.ResourceNotFound:
LOG.warn("Load balancer VIP port and subnet not found.")
LOG.warning("Load balancer VIP port and subnet not found.")
return None, None
except AttributeError:
LOG.warn("Load Balancer VIP port missing information.")
LOG.warning("Load Balancer VIP port missing information.")
return None, None
def _build_external_ids(self, loadbalancer, port):
@@ -3179,7 +3179,7 @@ class OvnProviderHelper():
try:
ls = self.ovn_nbdb_api.lookup('Logical_Switch', ls_name)
except idlutils.RowNotFound:
LOG.warn(f"Logical Switch {ls_name} not found.")
LOG.warning(f"Logical Switch {ls_name} not found.")
return
for port in ls.ports:
if port_id in port.name:
@@ -3211,9 +3211,9 @@ class OvnProviderHelper():
try:
return list(neutron_client.ips(port_id=lb.vip_port_id))
except openstack.exceptions.HttpException as e:
LOG.warn("Error on fetch fip for "
f"{lb.loadbalancer_id} "
f"Error: {str(e)}")
LOG.warning("Error on fetch fip for "
f"{lb.loadbalancer_id} "
f"Error: {str(e)}")
def _add_lbhc(self, ovn_lb, pool_key, info):
hm_id = info[constants.ID]

View File

@@ -17,7 +17,7 @@ import copy
import time
from unittest import mock
from neutron.common import utils as n_utils
from neutron.common import utils as n_utils # noqa: N530
from neutron_lib import constants as n_const
from neutron_lib.plugins import directory
from octavia_lib.api.drivers import data_models as octavia_data_model
@@ -33,7 +33,7 @@ import tenacity
# NOTE(mjozefcz): We need base neutron functionals because we need
# mechanism driver and l3 plugin.
from neutron.tests.functional import base
from neutron.tests.functional import base # noqa: N530
from ovn_octavia_provider.common import clients
from ovn_octavia_provider.common import constants as ovn_const
from ovn_octavia_provider import driver as ovn_driver
@@ -115,7 +115,7 @@ class TestOvnOctaviaBase(base.TestOVNFunctionalBase,
def _create_lb_model(self, vip=None, vip_network_id=None,
vip_subnet_id=None, vip_port_id=None,
admin_state_up=True, additional_vips=[]):
admin_state_up=True, additional_vips=None):
lb = octavia_data_model.LoadBalancer()
lb.loadbalancer_id = uuidutils.generate_uuid()
@@ -486,7 +486,7 @@ class TestOvnOctaviaBase(base.TestOVNFunctionalBase,
only_model=False,
router_id=None,
multiple_lb=False,
additional_vips=[]):
additional_vips=None):
self._o_driver_lib.update_loadbalancer_status.reset_mock()
lb_data = {}
if router_id:

View File

@@ -16,7 +16,7 @@
import atexit
import multiprocessing as mp
from neutron.common import utils as n_utils
from neutron.common import utils as n_utils # noqa: N530
from oslo_utils import uuidutils
from ovsdbapp.backend.ovs_idl import connection

View File

@@ -13,7 +13,7 @@
#
from unittest import mock
from neutron.tests import base
from neutron.tests import base # noqa: N530
from octavia_lib.api.drivers import driver_lib
from oslo_utils import uuidutils

View File

@@ -16,7 +16,7 @@
from unittest import mock
from neutron.tests import base
from neutron.tests import base # noqa: N530
from ovn_octavia_provider.common import config as ovn_config
from ovn_octavia_provider.common import utils

View File

@@ -15,7 +15,7 @@
import os
from unittest import mock
from neutron.tests import base
from neutron.tests import base # noqa: N530
from ovs.db import idl as ovs_idl
from ovsdbapp.backend import ovs_idl as real_ovs_idl
from ovsdbapp.backend.ovs_idl import idlutils

View File

@@ -917,7 +917,7 @@ class TestOvnProviderDriver(ovn_base.TestOvnOctaviaBase):
with mock.patch.object(ovn_driver, 'LOG') as m_l:
self.driver._fip_sync(self.ref_lb_fully_sync_populated)
m_l.warn.assert_has_calls(calls)
m_l.warning.assert_has_calls(calls)
@mock.patch('ovn_octavia_provider.common.clients.get_neutron_client')
def test_fip_sync_lsp_mismatch(self, net_cli):
@@ -934,7 +934,7 @@ class TestOvnProviderDriver(ovn_base.TestOvnOctaviaBase):
with mock.patch.object(ovn_driver, 'LOG') as m_l:
self.driver._fip_sync(self.ref_lb_fully_sync_populated)
m_l.warn.assert_called_once_with(msg)
m_l.warning.assert_called_once_with(msg)
@mock.patch('ovn_octavia_provider.common.clients.get_neutron_client')
def test_fip_sync_lsp_not_found(self, net_cli):
@@ -952,7 +952,7 @@ class TestOvnProviderDriver(ovn_base.TestOvnOctaviaBase):
with mock.patch.object(ovn_driver, 'LOG') as m_l:
self.driver._fip_sync(self.ref_lb_fully_sync_populated)
m_l.warn.assert_called_once_with(msg)
m_l.warning.assert_called_once_with(msg)
@mock.patch('ovn_octavia_provider.common.clients.get_neutron_client')
def test_fip_sync_no_neutron_fip(self, net_cli):
@@ -971,7 +971,7 @@ class TestOvnProviderDriver(ovn_base.TestOvnOctaviaBase):
self.mock_add_request
with mock.patch.object(ovn_driver, 'LOG') as m_l:
self.driver._fip_sync(self.ref_lb_fully_sync_populated)
m_l.warn.assert_has_calls(calls)
m_l.warning.assert_has_calls(calls)
@mock.patch('ovn_octavia_provider.common.clients.get_neutron_client')
def test_fip_sync_no_neutron_fip_no_lsp(self, net_cli):

View File

@@ -1045,7 +1045,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
net_cli.side_effect = [exceptions.DriverError]
with mock.patch.object(ovn_helper, 'LOG') as m_l:
self.assertFalse(self.helper.lb_sync(self.lb, self.ovn_lb))
m_l.warn.assert_called_once_with(
m_l.warning.assert_called_once_with(
('Cannot get client from neutron An unknown driver error '
'occurred.')
)
@@ -1057,7 +1057,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
m_gpri.side_effect = [AttributeError]
with mock.patch.object(ovn_helper, 'LOG') as m_l:
self.assertFalse(self.helper.lb_sync(self.lb, self.ovn_lb))
m_l.warn.assert_called_once_with(
m_l.warning.assert_called_once_with(
("Load Balancer VIP port missing information.")
)
@@ -1068,7 +1068,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
m_gpri.side_effect = [openstack.exceptions.ResourceNotFound]
with mock.patch.object(ovn_helper, 'LOG') as m_l:
self.assertFalse(self.helper.lb_sync(self.lb, self.ovn_lb))
m_l.warn.assert_called_once_with(
m_l.warning.assert_called_once_with(
("Load balancer VIP port and subnet not found.")
)
@@ -4457,7 +4457,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
with mock.patch.object(ovn_helper, 'LOG') as m_l:
self.assertIsNone(self.helper.get_lsp(port_id=port_id,
network_id=network_id))
m_l.warn.assert_called_once_with(
m_l.warning.assert_called_once_with(
f'Logical Switch neutron-{network_id} not found.')
def test_get_lsp_port_not_found(self):