Browse Source

ovn-metadata-agent: dsvm-functional issues due to str conversion

Fix string to byte convertion issues that were causing failure on the following tests:

TestMetadataAgent.test_agent_resync_on_non_existing_bridge
TestMetadataAgent.test_metadata_agent_healthcheck
TestMetadataAgent.test_agent_registration_at_chassis_create_event
TestMetadataAgent.test_updating_metadata_doesnt_update_controller_stats

networking_ovn.tests.functional.test_metadata_agent.TestMetadataAgent.test_agent_registration_at_chassis_create_event
---------------------------------------------------------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    b'Traceback (most recent call last):'
    b'  File "/opt/stack/networking-ovn/networking_ovn/tests/functional/test_metadata_agent.py", line 75, in setUp'
    b'    self.agent = self._start_metadata_agent()'
    b'  File "/opt/stack/networking-ovn/networking_ovn/tests/functional/test_metadata_agent.py", line 98, in _start_metadata_agent'
    b'    agt.start()'
    b'  File "/opt/stack/networking-ovn/networking_ovn/agent/metadata/agent.py", line 190, in start'
    b'    self.sync()'
    b'  File "/opt/stack/networking-ovn/networking_ovn/agent/metadata/agent.py", line 58, in wrapped'
    b'    return f(*args, **kwargs)'
    b'  File "/opt/stack/networking-ovn/networking_ovn/agent/metadata/agent.py", line 241, in sync'
    b'    unused_namespaces = [ns for ns in system_namespaces if'
    b'  File "/opt/stack/networking-ovn/networking_ovn/agent/metadata/agent.py", line 242, in <listcomp>'
    b'    ns.startswith(NS_PREFIX) and'
    b'TypeError: startswith first arg must be bytes or a tuple of bytes, not str'
    b''

Signed-off-by: Flavio Fernandes <flaviof@redhat.com>
Co-Authored-By: Terry Wilson <twilson@redhat.com>
Closes-Bug: #1843944
(cherry picked from commit 2832cee975)
Change-Id: Iaf807ab4bdbb41dc80702283d9689ccdd499fa31
tags/5.1.0
Flavio Fernandes 8 months ago
parent
commit
f0c9ede102
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      networking_ovn/agent/metadata/agent.py

+ 3
- 1
networking_ovn/agent/metadata/agent.py View File

@@ -237,7 +237,9 @@ class MetadataAgent(object):
which were serving metadata but are no longer needed.
"""
metadata_namespaces = self.ensure_all_networks_provisioned()
system_namespaces = ip_lib.list_network_namespaces()
system_namespaces = tuple(
ns.decode('utf-8') if isinstance(ns, bytes) else ns
for ns in ip_lib.list_network_namespaces())
unused_namespaces = [ns for ns in system_namespaces if
ns.startswith(NS_PREFIX) and
ns not in metadata_namespaces]


Loading…
Cancel
Save