Updates for OpenStack Newton

Ceilometer switched to using wsgi_script to generate the
ceilometer-api binary; this resulted in a few packaging changes,
including one which means the listen port for Ceilometer API is
set via the systemd unit, rather than the ceilometer.conf
configuration file.

Add systemd override file handling for ceilometer-api, including a
small workaround which ensures that the systemd daemon loads the
override configuration file when it changes (only possible during
config-changed with enabling SSL support).

This charm should switch to using Apache + mod_wsgi next cycle, at
which point all of that can just be dropped.


Change-Id: Ic8b359d0b91fda144925f5c75044f919e73aadd9
Closes-Bug: 1629796
This commit is contained in:
James Page 2016-10-03 13:05:26 +01:00 committed by Ryan Beisner
parent 6d2ef5da65
commit ac4d584e51
5 changed files with 75 additions and 3 deletions

View File

@ -37,7 +37,9 @@ from charmhelpers.core.hookenv import (
)
from charmhelpers.core.host import (
service_restart,
lsb_release
lsb_release,
mkdir,
init_is_systemd,
)
from charmhelpers.contrib.openstack.utils import (
configure_installation_source,
@ -53,6 +55,7 @@ from ceilometer_utils import (
CEILOMETER_DB,
CEILOMETER_SERVICE,
CEILOMETER_ROLE,
CEILOMETER_API_SYSTEMD_CONF,
register_configs,
restart_map,
services,
@ -61,6 +64,7 @@ from ceilometer_utils import (
do_openstack_upgrade,
set_shared_secret,
assess_status,
reload_systemd,
)
from ceilometer_contexts import CEILOMETER_PORT
from charmhelpers.contrib.openstack.ip import (
@ -101,6 +105,10 @@ def install():
apt_update(fatal=True)
apt_install(packages, fatal=True)
open_port(CEILOMETER_PORT)
if init_is_systemd():
# NOTE(jamespage): ensure systemd override folder exists prior to
# attempting to write override.conf
mkdir(os.path.dirname(CEILOMETER_API_SYSTEMD_CONF))
@hooks.hook("amqp-relation-joined")
@ -173,6 +181,9 @@ def config_changed():
do_openstack_upgrade(CONFIGS)
update_nrpe_config()
CONFIGS.write_all()
# NOTE(jamespage): Drop when charm switches to apache2+mod_wsgi
# reload ensures port override is set correctly
reload_systemd()
ceilometer_joined()
configure_https()
for rid in relation_ids('identity-service'):

View File

@ -14,6 +14,7 @@
import os
import uuid
import subprocess
from collections import OrderedDict
@ -40,11 +41,15 @@ from charmhelpers.contrib.openstack.utils import (
)
from charmhelpers.core.hookenv import config, log
from charmhelpers.fetch import apt_update, apt_install, apt_upgrade
from charmhelpers.core.host import init_is_systemd
from copy import deepcopy
HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'
CEILOMETER_CONF_DIR = "/etc/ceilometer"
CEILOMETER_CONF = "%s/ceilometer.conf" % CEILOMETER_CONF_DIR
CEILOMETER_API_SYSTEMD_CONF = (
'/etc/systemd/system/ceilometer-api.service.d/override.conf'
)
HTTPS_APACHE_CONF = "/etc/apache2/sites-available/openstack_https_frontend"
HTTPS_APACHE_24_CONF = "/etc/apache2/sites-available/" \
"openstack_https_frontend.conf"
@ -109,6 +114,10 @@ CONFIG_FILES = OrderedDict([
HAProxyContext()],
'services': CEILOMETER_BASE_SERVICES
}),
(CEILOMETER_API_SYSTEMD_CONF, {
'hook_contexts': [HAProxyContext()],
'services': ['ceilometer-api'],
}),
(HAPROXY_CONF, {
'hook_contexts': [context.HAProxyContext(singlenode_mode=True),
HAProxyContext()],
@ -145,9 +154,15 @@ def register_configs():
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release)
for conf in CONFIG_FILES:
for conf in (CEILOMETER_CONF, HAPROXY_CONF):
configs.register(conf, CONFIG_FILES[conf]['hook_contexts'])
if init_is_systemd():
configs.register(
CEILOMETER_API_SYSTEMD_CONF,
CONFIG_FILES[CEILOMETER_API_SYSTEMD_CONF]['hook_contexts']
)
if os.path.exists('/etc/apache2/conf-available'):
configs.register(HTTPS_APACHE_24_CONF,
CONFIG_FILES[HTTPS_APACHE_24_CONF]['hook_contexts'])
@ -353,3 +368,11 @@ def _pause_resume_helper(f, configs):
f(assess_status_func(configs),
services=services(),
ports=determine_ports())
# NOTE(jamespage): Drop once charm switches to apache+mod_wsgi.
def reload_systemd():
"""Reload systemd configuration on systemd based installs
"""
if init_is_systemd():
subprocess.check_call(['systemctl', 'daemon-reload'])

2
templates/override.conf Normal file
View File

@ -0,0 +1,2 @@
[Service]
Environment=PORT={{ port }}

View File

@ -63,6 +63,9 @@ TO_PATCH = [
'configure_https',
'status_set',
'update_dns_ha_resource_params',
'reload_systemd',
'mkdir',
'init_is_systemd',
]
@ -153,6 +156,7 @@ class CeilometerHooksTest(CharmTestCase):
self.assertFalse(self.do_openstack_upgrade.called)
self.assertTrue(self.CONFIGS.write_all.called)
self.assertTrue(joined.called)
self.assertTrue(self.reload_systemd.called)
@patch('charmhelpers.core.hookenv.config')
@patch.object(hooks, 'ceilometer_joined')
@ -164,6 +168,7 @@ class CeilometerHooksTest(CharmTestCase):
self.assertTrue(self.do_openstack_upgrade.called)
self.assertTrue(self.CONFIGS.write_all.called)
self.assertTrue(joined.called)
self.assertTrue(self.reload_systemd.called)
def test_config_changed_with_openstack_upgrade_action(self):
self.openstack_upgrade_available.return_value = True

View File

@ -32,6 +32,8 @@ TO_PATCH = [
'apt_update',
'apt_upgrade',
'os_application_version_set',
'init_is_systemd',
'os',
]
@ -45,9 +47,34 @@ class CeilometerUtilsTest(CharmTestCase):
super(CeilometerUtilsTest, self).tearDown()
def test_register_configs(self):
self.os.path.exists.return_value = True
self.init_is_systemd.return_value = False
configs = utils.register_configs()
calls = []
for conf in utils.CONFIG_FILES:
for conf in (utils.CEILOMETER_CONF, utils.HAPROXY_CONF,
utils.HTTPS_APACHE_24_CONF):
calls.append(call(conf,
utils.CONFIG_FILES[conf]['hook_contexts']))
configs.register.assert_has_calls(calls, any_order=True)
def test_register_configs_apache22(self):
self.os.path.exists.return_value = False
self.init_is_systemd.return_value = False
configs = utils.register_configs()
calls = []
for conf in (utils.CEILOMETER_CONF, utils.HAPROXY_CONF,
utils.HTTPS_APACHE_CONF):
calls.append(call(conf,
utils.CONFIG_FILES[conf]['hook_contexts']))
configs.register.assert_has_calls(calls, any_order=True)
def test_register_configs_systemd(self):
self.os.path.exists.return_value = True
self.init_is_systemd.return_value = True
configs = utils.register_configs()
calls = []
for conf in (utils.CEILOMETER_CONF, utils.HAPROXY_CONF,
utils.HTTPS_APACHE_24_CONF):
calls.append(call(conf,
utils.CONFIG_FILES[conf]['hook_contexts']))
configs.register.assert_has_calls(calls, any_order=True)
@ -79,6 +106,8 @@ class CeilometerUtilsTest(CharmTestCase):
'ceilometer-alarm-notifier',
'ceilometer-alarm-evaluator',
'ceilometer-agent-notification'],
'/etc/systemd/system/ceilometer-api.service.d/override.conf': [
'ceilometer-api'],
'/etc/haproxy/haproxy.cfg': ['haproxy'],
"/etc/apache2/sites-available/openstack_https_frontend": [
'apache2'],
@ -98,6 +127,8 @@ class CeilometerUtilsTest(CharmTestCase):
'ceilometer-collector',
'ceilometer-api',
'ceilometer-agent-notification'],
'/etc/systemd/system/ceilometer-api.service.d/override.conf': [
'ceilometer-api'],
'/etc/haproxy/haproxy.cfg': ['haproxy'],
"/etc/apache2/sites-available/openstack_https_frontend": [
'apache2'],