Merge "Add state reporting back to metadata agents"

This commit is contained in:
Zuul
2025-06-13 23:38:57 +00:00
committed by Gerrit Code Review
5 changed files with 40 additions and 8 deletions

View File

@@ -235,4 +235,5 @@ class UnixDomainMetadataProxy(proxy_base.UnixDomainMetadataProxyBase):
self._server = socketserver.ThreadingUnixStreamServer(
file_socket, MetadataProxyHandler)
MetadataProxyHandler._conf = self.conf
self._init_state_reporting()
self._server.serve_forever()

View File

@@ -10,10 +10,15 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
# NOTE(haleyb): remove once the default backend is ``BackendType.THREADING``
import oslo_service.backend as service
service.init_backend(service.BackendType.THREADING)
from neutron.agent import metadata_agent
from neutron_lib import constants
# pylint: disable=wrong-import-position
import setproctitle # noqa: E402
from neutron.agent import metadata_agent # noqa: E402
from neutron_lib import constants # noqa: E402
def main():

View File

@@ -10,10 +10,15 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
# NOTE(haleyb): remove once the default backend is ``BackendType.THREADING``
import oslo_service.backend as service
service.init_backend(service.BackendType.THREADING)
from neutron.agent.ovn import metadata_agent
from neutron_lib import constants
# pylint: disable=wrong-import-position
import setproctitle # noqa: E402
from neutron.agent.ovn import metadata_agent # noqa: E402
from neutron_lib import constants # noqa: E402
def main():

View File

@@ -10,9 +10,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import setproctitle
# NOTE(haleyb): remove once the default backend is ``BackendType.THREADING``
import oslo_service.backend as service
service.init_backend(service.BackendType.THREADING)
from neutron.agent.ovn import ovn_neutron_agent
# pylint: disable=wrong-import-position
import setproctitle # noqa: E402
from neutron.agent.ovn import ovn_neutron_agent # noqa: E402
# TODO(ralonsoh): move to ``neutron_lib.constants``.

View File

@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import socketserver
from unittest import mock
import ddt
@@ -435,6 +436,21 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
agent.UnixDomainMetadataProxy(mock.Mock())
unlink.assert_called_once_with('/the/path')
@mock.patch.object(agent, 'MetadataProxyHandler')
@mock.patch.object(socketserver, 'ThreadingUnixStreamServer')
@mock.patch.object(fileutils, 'ensure_tree')
def test_run(self, ensure_dir, server, handler):
p = agent.UnixDomainMetadataProxy(self.cfg.CONF)
p.run()
ensure_dir.assert_called_once_with('/the', mode=0o755)
server.assert_has_calls([
mock.call('/the/path', mock.ANY),
mock.call().serve_forever()])
self.looping_mock.assert_called_once_with(p._report_state)
self.looping_mock.return_value.start.assert_called_once_with(
interval=mock.ANY)
def test_main(self):
with mock.patch.object(agent, 'UnixDomainMetadataProxy') as proxy:
with mock.patch.object(metadata_agent, 'config') as config: