Merge "Fix Amphora controller IP list update"
This commit is contained in:
@@ -56,7 +56,7 @@ def register_app_error_handler(app):
|
||||
|
||||
|
||||
class Server:
|
||||
def __init__(self):
|
||||
def __init__(self, hm_queue):
|
||||
self.app = flask.Flask(__name__)
|
||||
self._osutils = osutils.BaseOS.get_os_util()
|
||||
self._keepalived = keepalived.Keepalived()
|
||||
@@ -64,6 +64,7 @@ class Server:
|
||||
self._lvs_listener = keepalivedlvs.KeepalivedLvs()
|
||||
self._plug = plug.Plug(self._osutils)
|
||||
self._amphora_info = amphora_info.AmphoraInfo(self._osutils)
|
||||
self._hm_queue = hm_queue
|
||||
|
||||
register_app_error_handler(self.app)
|
||||
|
||||
@@ -253,6 +254,8 @@ class Server:
|
||||
b = stream.read(BUFFER)
|
||||
|
||||
CONF.mutate_config_files()
|
||||
# Signal to the health manager process to reload it's configuration
|
||||
self._hm_queue.put('reload')
|
||||
except Exception as e:
|
||||
LOG.error("Unable to update amphora-agent configuration: %s",
|
||||
str(e))
|
||||
|
@@ -31,7 +31,6 @@ from octavia import version
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
HM_SENDER_CMD_QUEUE = multiproc.Queue()
|
||||
|
||||
|
||||
class AmphoraAgent(gunicorn.app.base.BaseApplication):
|
||||
@@ -58,14 +57,19 @@ def main():
|
||||
gmr_opts.set_defaults(CONF)
|
||||
gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)
|
||||
|
||||
# Setup a multiprocessing manager and queue to share between the
|
||||
# health manager sender and the workers. This allows us to reload the
|
||||
# configuration into the health manager sender process.
|
||||
hm_queue = multiproc.Manager().Queue()
|
||||
|
||||
health_sender_proc = multiproc.Process(name='HM_sender',
|
||||
target=health_daemon.run_sender,
|
||||
args=(HM_SENDER_CMD_QUEUE,))
|
||||
args=(hm_queue,))
|
||||
health_sender_proc.daemon = True
|
||||
health_sender_proc.start()
|
||||
|
||||
# Initiate server class
|
||||
server_instance = server.Server()
|
||||
server_instance = server.Server(hm_queue)
|
||||
|
||||
bind_ip_port = utils.ip_port_str(CONF.haproxy_amphora.bind_host,
|
||||
CONF.haproxy_amphora.bind_port)
|
||||
|
@@ -57,16 +57,17 @@ class TestServerTestCase(base.TestCase):
|
||||
self.useFixture(fixtures.MockPatch(
|
||||
'oslo_config.cfg.find_config_files',
|
||||
return_value=[AMP_AGENT_CONF_PATH]))
|
||||
hm_queue = mock.MagicMock()
|
||||
with mock.patch('distro.id', return_value='ubuntu'), mock.patch(
|
||||
'octavia.amphorae.backends.agent.api_server.plug.'
|
||||
'Plug.plug_lo'):
|
||||
self.ubuntu_test_server = server.Server()
|
||||
self.ubuntu_test_server = server.Server(hm_queue)
|
||||
self.ubuntu_app = self.ubuntu_test_server.app.test_client()
|
||||
|
||||
with mock.patch('distro.id', return_value='centos'), mock.patch(
|
||||
'octavia.amphorae.backends.agent.api_server.plug.'
|
||||
'Plug.plug_lo'):
|
||||
self.centos_test_server = server.Server()
|
||||
self.centos_test_server = server.Server(hm_queue)
|
||||
self.centos_app = self.centos_test_server.app.test_client()
|
||||
|
||||
def test_ubuntu_haproxy(self):
|
||||
@@ -2887,10 +2888,11 @@ class TestServerTestCase(base.TestCase):
|
||||
self.assertEqual(500, rv.status_code)
|
||||
|
||||
def test_version_discovery(self):
|
||||
hm_queue = mock.MagicMock()
|
||||
with mock.patch('distro.id', return_value='ubuntu'), mock.patch(
|
||||
'octavia.amphorae.backends.agent.api_server.plug.'
|
||||
'Plug.plug_lo'):
|
||||
self.test_client = server.Server().app.test_client()
|
||||
self.test_client = server.Server(hm_queue).app.test_client()
|
||||
expected_dict = {'api_version': api_server.VERSION}
|
||||
rv = self.test_client.get('/')
|
||||
self.assertEqual(200, rv.status_code)
|
||||
|
@@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixed a bug where the Amphora configuration update would only update the
|
||||
Amphora agent configuration, but the health sender would not be updated
|
||||
with the new controller IP list.
|
Reference in New Issue
Block a user