Monkey patch threading module as early as possible
In oslo.messaging, local thread store is used to pass RPC request context [1]. If we try to import oslo.messaging before monkey patching threading library, it attempts to access unpatched storage and fails with AttributeError. [1]: oslo/messaging/localcontext.py#L26 blueprint oslo-messaging Change-Id: Ied7302fcb1d3e14428540e39e3db704550027890
This commit is contained in:
parent
fc8546d8c0
commit
161ec8341b
@ -18,6 +18,8 @@
|
||||
import os
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
import netaddr
|
||||
from oslo.config import cfg
|
||||
|
||||
@ -607,7 +609,6 @@ def register_options():
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
register_options()
|
||||
cfg.CONF(project='neutron')
|
||||
config.setup_logging(cfg.CONF)
|
||||
|
@ -14,6 +14,8 @@
|
||||
#
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
import netaddr
|
||||
from oslo.config import cfg
|
||||
|
||||
@ -967,7 +969,6 @@ class L3NATAgentWithStateReport(L3NATAgent):
|
||||
|
||||
|
||||
def main(manager='neutron.agent.l3_agent.L3NATAgentWithStateReport'):
|
||||
eventlet.monkey_patch()
|
||||
conf = cfg.CONF
|
||||
conf.register_opts(L3NATAgent.OPTS)
|
||||
config.register_interface_driver_opts_helper(conf)
|
||||
|
@ -22,6 +22,8 @@ import os
|
||||
import socket
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
import httplib2
|
||||
from neutronclient.v2_0 import client
|
||||
from oslo.config import cfg
|
||||
@ -377,7 +379,6 @@ class UnixDomainMetadataProxy(object):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
cfg.CONF.register_opts(UnixDomainMetadataProxy.OPTS)
|
||||
cfg.CONF.register_opts(MetadataProxyHandler.OPTS)
|
||||
cache.register_oslo_configs(cfg.CONF)
|
||||
|
@ -20,6 +20,8 @@ import httplib
|
||||
import socket
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
import httplib2
|
||||
from oslo.config import cfg
|
||||
import six.moves.urllib.parse as urlparse
|
||||
@ -144,7 +146,6 @@ class ProxyDaemon(daemon.Daemon):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
opts = [
|
||||
cfg.StrOpt('network_id',
|
||||
help=_('Network that will have instance metadata '
|
||||
|
@ -18,6 +18,8 @@
|
||||
import re
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.agent.common import config as agent_config
|
||||
@ -157,8 +159,6 @@ def main():
|
||||
installation as it will blindly purge namespaces and their devices. This
|
||||
option also kills any lingering DHCP instances.
|
||||
"""
|
||||
eventlet.monkey_patch()
|
||||
|
||||
conf = setup_conf()
|
||||
conf()
|
||||
config.setup_logging(conf)
|
||||
|
@ -17,10 +17,12 @@
|
||||
# under the License.
|
||||
# @author: Kevin Benton, kevin.benton@bigswitch.com
|
||||
|
||||
import eventlet
|
||||
import sys
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.agent.linux import ovs_lib
|
||||
@ -162,7 +164,6 @@ class RestProxyAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
cfg.CONF(project='neutron')
|
||||
config.setup_logging(cfg.CONF)
|
||||
pl_config.register_config()
|
||||
|
@ -18,11 +18,13 @@
|
||||
# @author: Pedro Navarro Perez
|
||||
# @author: Alessandro Pilotti, Cloudbase Solutions Srl
|
||||
|
||||
import eventlet
|
||||
import platform
|
||||
import re
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.agent.common import config
|
||||
@ -464,7 +466,6 @@ class HyperVNeutronAgent(object):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
cfg.CONF(project='neutron')
|
||||
logging_config.setup_logging(cfg.CONF)
|
||||
|
||||
|
@ -21,6 +21,8 @@ import socket
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.agent.linux import ip_lib
|
||||
@ -252,7 +254,6 @@ def create_agent_config_map(config):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
cfg.CONF.register_opts(ip_lib.OPTS)
|
||||
cfg.CONF(project='neutron')
|
||||
logging_config.setup_logging(cfg.CONF)
|
||||
|
@ -27,6 +27,8 @@ import sys
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.agent import l2population_rpc as l2pop_rpc
|
||||
@ -1025,7 +1027,6 @@ class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
cfg.CONF(project='neutron')
|
||||
|
||||
logging_config.setup_logging(cfg.CONF)
|
||||
|
@ -21,6 +21,8 @@ import sys
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.agent import rpc as agent_rpc
|
||||
@ -417,7 +419,6 @@ class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
cfg.CONF(project='neutron')
|
||||
logging_config.setup_logging(cfg.CONF)
|
||||
|
||||
|
@ -24,6 +24,7 @@ import socket
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from neutron.agent.linux import ovs_lib
|
||||
from neutron.agent import rpc as agent_rpc
|
||||
@ -230,8 +231,6 @@ class NECNeutronAgent(object):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
|
||||
config.CONF(project='neutron')
|
||||
|
||||
logging_config.setup_logging(config.CONF)
|
||||
|
@ -20,6 +20,7 @@ import socket
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from neutron.agent.linux import ovs_lib
|
||||
from neutron.agent import rpc as agent_rpc
|
||||
@ -160,7 +161,6 @@ class NVSDNeutronAgent(object):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
config.CONF(project='neutron')
|
||||
logging_config.setup_logging(config.CONF)
|
||||
|
||||
|
@ -19,6 +19,8 @@ import sys
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
import netaddr
|
||||
from oslo.config import cfg
|
||||
from six import moves
|
||||
@ -1461,7 +1463,6 @@ def create_agent_config_map(config):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
cfg.CONF.register_opts(ip_lib.OPTS)
|
||||
cfg.CONF(project='neutron')
|
||||
logging_config.setup_logging(cfg.CONF)
|
||||
|
@ -24,6 +24,8 @@ import sys
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from oslo.config import cfg
|
||||
from ryu.app import client
|
||||
from ryu.app import conf_switch_key
|
||||
@ -282,7 +284,6 @@ class OVSNeutronOFPRyuAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
cfg.CONF(project='neutron')
|
||||
|
||||
logging_config.setup_logging(cfg.CONF)
|
||||
|
@ -15,14 +15,15 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import eventlet
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.vmware.api_client import base
|
||||
from neutron.plugins.vmware.api_client import eventlet_request
|
||||
|
||||
eventlet.monkey_patch()
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -18,9 +18,11 @@
|
||||
# If ../neutron/__init__.py exists, add ../ to Python search path, so that
|
||||
# it will override what happens to be installed in /usr/(local/)lib/python...
|
||||
|
||||
import eventlet
|
||||
import sys
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.common import config
|
||||
@ -34,8 +36,6 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
|
||||
# the configuration will be read into the cfg.CONF global data structure
|
||||
config.parse(sys.argv[1:])
|
||||
if not cfg.CONF.config_file:
|
||||
|
@ -19,6 +19,8 @@
|
||||
#
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
import netaddr
|
||||
from oslo.config import cfg
|
||||
|
||||
@ -327,7 +329,6 @@ class vArmourL3NATAgentWithStateReport(vArmourL3NATAgent,
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
conf = cfg.CONF
|
||||
conf.register_opts(vArmourL3NATAgent.OPTS)
|
||||
config.register_interface_driver_opts_helper(conf)
|
||||
|
@ -17,6 +17,8 @@
|
||||
# @author: Mark McClain, DreamHost
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.agent.common import config
|
||||
@ -47,7 +49,6 @@ class LbaasAgentService(rpc_service.Service):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
cfg.CONF.register_opts(OPTS)
|
||||
cfg.CONF.register_opts(manager.OPTS)
|
||||
# import interface options just in case the driver uses namespaces
|
||||
|
@ -25,6 +25,8 @@ import time
|
||||
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch(thread=True)
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
@ -39,8 +41,6 @@ from neutron.plugins.common import constants
|
||||
from neutron.services.loadbalancer.drivers import abstract_driver
|
||||
from neutron.services.loadbalancer.drivers.radware import exceptions as r_exc
|
||||
|
||||
eventlet.monkey_patch(thread=True)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
RESP_STATUS = 0
|
||||
|
@ -17,6 +17,8 @@
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.agent.common import config
|
||||
@ -281,7 +283,6 @@ class MeteringAgentWithStateReport(MeteringAgent):
|
||||
|
||||
|
||||
def main():
|
||||
eventlet.monkey_patch()
|
||||
conf = cfg.CONF
|
||||
conf.register_opts(MeteringAgent.Opts)
|
||||
config.register_agent_state_opts_helper(conf)
|
||||
|
@ -213,14 +213,12 @@ class TestHyperVNeutronAgent(base.BaseTestCase):
|
||||
with mock.patch.object(hyperv_neutron_agent,
|
||||
'HyperVNeutronAgent') as plugin:
|
||||
with mock.patch.object(hyperv_neutron_agent.cfg, 'CONF') as cfg:
|
||||
with mock.patch('eventlet.monkey_patch') as eventlet:
|
||||
with mock.patch.object(
|
||||
hyperv_neutron_agent,
|
||||
'logging_config') as logging_config:
|
||||
with mock.patch.object(
|
||||
hyperv_neutron_agent,
|
||||
'logging_config') as logging_config:
|
||||
|
||||
hyperv_neutron_agent.main()
|
||||
hyperv_neutron_agent.main()
|
||||
|
||||
self.assertTrue(cfg.called)
|
||||
self.assertTrue(eventlet.called)
|
||||
self.assertTrue(logging_config.setup_logging.called)
|
||||
plugin.assert_has_calls([mock.call().daemon_loop()])
|
||||
self.assertTrue(cfg.called)
|
||||
self.assertTrue(logging_config.setup_logging.called)
|
||||
plugin.assert_has_calls([mock.call().daemon_loop()])
|
||||
|
@ -350,17 +350,15 @@ class TestNecAgentMain(base.BaseTestCase):
|
||||
def test_main(self):
|
||||
with contextlib.nested(
|
||||
mock.patch.object(nec_neutron_agent, 'NECNeutronAgent'),
|
||||
mock.patch('eventlet.monkey_patch'),
|
||||
mock.patch.object(nec_neutron_agent, 'logging_config'),
|
||||
mock.patch.object(nec_neutron_agent, 'config')
|
||||
) as (agent, eventlet, logging_config, cfg):
|
||||
) as (agent, logging_config, cfg):
|
||||
cfg.OVS.integration_bridge = 'br-int-x'
|
||||
cfg.AGENT.root_helper = 'dummy-helper'
|
||||
cfg.AGENT.polling_interval = 10
|
||||
|
||||
nec_neutron_agent.main()
|
||||
|
||||
self.assertTrue(eventlet.called)
|
||||
self.assertTrue(logging_config.setup_logging.called)
|
||||
agent.assert_has_calls([
|
||||
mock.call('br-int-x', 'dummy-helper', 10),
|
||||
|
@ -161,17 +161,15 @@ class TestOneConvergenceAgentMain(base.BaseTestCase):
|
||||
def test_main(self):
|
||||
with contextlib.nested(
|
||||
mock.patch.object(nvsd_neutron_agent, 'NVSDNeutronAgent'),
|
||||
mock.patch('eventlet.monkey_patch'),
|
||||
mock.patch.object(nvsd_neutron_agent, 'logging_config'),
|
||||
mock.patch.object(nvsd_neutron_agent, 'config')
|
||||
) as (agent, eventlet, logging_config, config):
|
||||
) as (agent, logging_config, config):
|
||||
config.AGENT.integration_bridge = 'br-int-dummy'
|
||||
config.AGENT.root_helper = 'root-helper'
|
||||
config.AGENT.polling_interval = 5
|
||||
|
||||
nvsd_neutron_agent.main()
|
||||
|
||||
self.assertTrue(eventlet.called)
|
||||
self.assertTrue(logging_config.setup_logging.called)
|
||||
agent.assert_has_calls([
|
||||
mock.call('br-int-dummy', 'root-helper', 5),
|
||||
|
@ -42,12 +42,10 @@ class TestLbaasService(base.BaseTestCase):
|
||||
with contextlib.nested(
|
||||
mock.patch(logging_str),
|
||||
mock.patch.object(agent.service, 'launch'),
|
||||
mock.patch.object(agent, 'eventlet'),
|
||||
mock.patch('sys.argv'),
|
||||
mock.patch.object(agent.manager, 'LbaasAgentManager'),
|
||||
mock.patch.object(cfg.CONF, 'register_opts')
|
||||
) as (mock_logging, mock_launch, mock_eventlet, sys_argv, mgr_cls, ro):
|
||||
) as (mock_logging, mock_launch, sys_argv, mgr_cls, ro):
|
||||
agent.main()
|
||||
|
||||
self.assertTrue(mock_eventlet.monkey_patch.called)
|
||||
mock_launch.assert_called_once_with(mock.ANY)
|
||||
|
@ -551,18 +551,16 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
|
||||
|
||||
def test_main(self):
|
||||
with mock.patch.object(agent, 'UnixDomainMetadataProxy') as proxy:
|
||||
with mock.patch('eventlet.monkey_patch') as eventlet:
|
||||
with mock.patch.object(agent, 'config') as config:
|
||||
with mock.patch.object(agent, 'cfg') as cfg:
|
||||
with mock.patch.object(utils, 'cfg'):
|
||||
agent.main()
|
||||
with mock.patch.object(agent, 'config') as config:
|
||||
with mock.patch.object(agent, 'cfg') as cfg:
|
||||
with mock.patch.object(utils, 'cfg'):
|
||||
agent.main()
|
||||
|
||||
self.assertTrue(eventlet.called)
|
||||
self.assertTrue(config.setup_logging.called)
|
||||
proxy.assert_has_calls([
|
||||
mock.call(cfg.CONF),
|
||||
mock.call().run()]
|
||||
)
|
||||
self.assertTrue(config.setup_logging.called)
|
||||
proxy.assert_has_calls([
|
||||
mock.call(cfg.CONF),
|
||||
mock.call().run()]
|
||||
)
|
||||
|
||||
def test_init_state_reporting(self):
|
||||
with mock.patch('os.makedirs'):
|
||||
|
@ -312,46 +312,42 @@ class TestProxyDaemon(base.BaseTestCase):
|
||||
|
||||
def test_main(self):
|
||||
with mock.patch.object(ns_proxy, 'ProxyDaemon') as daemon:
|
||||
with mock.patch('eventlet.monkey_patch') as eventlet:
|
||||
with mock.patch.object(ns_proxy, 'config') as config:
|
||||
with mock.patch.object(ns_proxy, 'cfg') as cfg:
|
||||
with mock.patch.object(utils, 'cfg') as utils_cfg:
|
||||
cfg.CONF.router_id = 'router_id'
|
||||
cfg.CONF.network_id = None
|
||||
cfg.CONF.metadata_port = 9697
|
||||
cfg.CONF.pid_file = 'pidfile'
|
||||
cfg.CONF.daemonize = True
|
||||
utils_cfg.CONF.log_opt_values.return_value = None
|
||||
ns_proxy.main()
|
||||
with mock.patch.object(ns_proxy, 'config') as config:
|
||||
with mock.patch.object(ns_proxy, 'cfg') as cfg:
|
||||
with mock.patch.object(utils, 'cfg') as utils_cfg:
|
||||
cfg.CONF.router_id = 'router_id'
|
||||
cfg.CONF.network_id = None
|
||||
cfg.CONF.metadata_port = 9697
|
||||
cfg.CONF.pid_file = 'pidfile'
|
||||
cfg.CONF.daemonize = True
|
||||
utils_cfg.CONF.log_opt_values.return_value = None
|
||||
ns_proxy.main()
|
||||
|
||||
self.assertTrue(eventlet.called)
|
||||
self.assertTrue(config.setup_logging.called)
|
||||
daemon.assert_has_calls([
|
||||
mock.call('pidfile', 9697,
|
||||
router_id='router_id',
|
||||
network_id=None),
|
||||
mock.call().start()]
|
||||
)
|
||||
self.assertTrue(config.setup_logging.called)
|
||||
daemon.assert_has_calls([
|
||||
mock.call('pidfile', 9697,
|
||||
router_id='router_id',
|
||||
network_id=None),
|
||||
mock.call().start()]
|
||||
)
|
||||
|
||||
def test_main_dont_fork(self):
|
||||
with mock.patch.object(ns_proxy, 'ProxyDaemon') as daemon:
|
||||
with mock.patch('eventlet.monkey_patch') as eventlet:
|
||||
with mock.patch.object(ns_proxy, 'config') as config:
|
||||
with mock.patch.object(ns_proxy, 'cfg') as cfg:
|
||||
with mock.patch.object(utils, 'cfg') as utils_cfg:
|
||||
cfg.CONF.router_id = 'router_id'
|
||||
cfg.CONF.network_id = None
|
||||
cfg.CONF.metadata_port = 9697
|
||||
cfg.CONF.pid_file = 'pidfile'
|
||||
cfg.CONF.daemonize = False
|
||||
utils_cfg.CONF.log_opt_values.return_value = None
|
||||
ns_proxy.main()
|
||||
with mock.patch.object(ns_proxy, 'config') as config:
|
||||
with mock.patch.object(ns_proxy, 'cfg') as cfg:
|
||||
with mock.patch.object(utils, 'cfg') as utils_cfg:
|
||||
cfg.CONF.router_id = 'router_id'
|
||||
cfg.CONF.network_id = None
|
||||
cfg.CONF.metadata_port = 9697
|
||||
cfg.CONF.pid_file = 'pidfile'
|
||||
cfg.CONF.daemonize = False
|
||||
utils_cfg.CONF.log_opt_values.return_value = None
|
||||
ns_proxy.main()
|
||||
|
||||
self.assertTrue(eventlet.called)
|
||||
self.assertTrue(config.setup_logging.called)
|
||||
daemon.assert_has_calls([
|
||||
mock.call('pidfile', 9697,
|
||||
router_id='router_id',
|
||||
network_id=None),
|
||||
mock.call().run()]
|
||||
)
|
||||
self.assertTrue(config.setup_logging.called)
|
||||
daemon.assert_has_calls([
|
||||
mock.call('pidfile', 9697,
|
||||
router_id='router_id',
|
||||
network_id=None),
|
||||
mock.call().run()]
|
||||
)
|
||||
|
@ -30,7 +30,7 @@ from xml.etree import ElementTree as etree
|
||||
from xml.parsers import expat
|
||||
|
||||
import eventlet.wsgi
|
||||
eventlet.patcher.monkey_patch(all=False, socket=True)
|
||||
eventlet.patcher.monkey_patch(all=False, socket=True, thread=True)
|
||||
from oslo.config import cfg
|
||||
import routes.middleware
|
||||
import webob.dec
|
||||
|
Loading…
Reference in New Issue
Block a user