diff --git a/neutron/agent/resource_cache.py b/neutron/agent/resource_cache.py index 10b68f2309..bfcc06990f 100644 --- a/neutron/agent/resource_cache.py +++ b/neutron/agent/resource_cache.py @@ -49,6 +49,9 @@ class RemoteResourceCache(object): def start_watcher(self): self._watcher = RemoteResourceWatcher(self) + def stop(self): + self._watcher.stop() + def get_resource_by_id(self, rtype, obj_id, agent_restarted=False): """Returns None if it doesn't exist.""" if obj_id in self._deleted_ids_by_type[rtype]: @@ -263,3 +266,6 @@ class RemoteResourceWatcher(object): else: # creates and updates are treated equally self.rcache.record_resource_update(context, rtype, r) + + def stop(self): + self._connection.close() diff --git a/neutron/agent/rpc.py b/neutron/agent/rpc.py index dc4c27ab18..8a912c1006 100644 --- a/neutron/agent/rpc.py +++ b/neutron/agent/rpc.py @@ -398,6 +398,9 @@ class CacheBackedPluginApi(PluginApi): rcache.start_watcher() self.remote_resource_cache = rcache + def stop(self): + self.remote_resource_cache.stop() + # TODO(ralonsoh): move this method to neutron_lib.plugins.utils def migrating_to_host(bindings, host=None): diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py index ca94a09488..a0281d9704 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -2812,6 +2812,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, bridge_names=bridge_names, ovs=self.ovs) as pm: self.rpc_loop(polling_manager=pm) + if self.plugin_rpc: + self.plugin_rpc.stop() def _handle_sigterm(self, signum, frame): self.catch_sigterm = True