Fix service enablement during init

Some services were disabled in the install hook and then started during
the init phase without being enabled. Thus, after a machine restart they
were not brought back up by systemd.

Change-Id: I27f7d7fa6b8df104567b91b5bc998ebe98b478a2
This commit is contained in:
Dmitrii Shcherbakov 2020-11-11 10:10:31 +00:00
parent 6087f4cb3b
commit a2cc37e278
2 changed files with 30 additions and 41 deletions

View File

@ -24,12 +24,15 @@ snapctl stop --disable $SNAP_INSTANCE_NAME.nova-api-metadata
snapctl stop --disable $SNAP_INSTANCE_NAME.nova-spicehtml5proxy snapctl stop --disable $SNAP_INSTANCE_NAME.nova-spicehtml5proxy
snapctl stop --disable $SNAP_INSTANCE_NAME.nova-scheduler snapctl stop --disable $SNAP_INSTANCE_NAME.nova-scheduler
snapctl stop --disable $SNAP_INSTANCE_NAME.horizon-uwsgi
snapctl stop --disable $SNAP_INSTANCE_NAME.neutron-api snapctl stop --disable $SNAP_INSTANCE_NAME.neutron-api
snapctl stop --disable $SNAP_INSTANCE_NAME.glance-api snapctl stop --disable $SNAP_INSTANCE_NAME.glance-api
snapctl stop --disable $SNAP_INSTANCE_NAME.registry snapctl stop --disable $SNAP_INSTANCE_NAME.registry
snapctl stop --disable $SNAP_INSTANCE_NAME.cinder-uwsgi snapctl stop --disable $SNAP_INSTANCE_NAME.cinder-uwsgi
snapctl stop --disable $SNAP_INSTANCE_NAME.cinder-scheduler
snapctl stop --disable $SNAP_INSTANCE_NAME.ovsdb-server snapctl stop --disable $SNAP_INSTANCE_NAME.ovsdb-server
snapctl stop --disable $SNAP_INSTANCE_NAME.neutron-ovn-metadata-agent snapctl stop --disable $SNAP_INSTANCE_NAME.neutron-ovn-metadata-agent
@ -39,6 +42,9 @@ snapctl stop --disable $SNAP_INSTANCE_NAME.ovs-vswitchd
snapctl stop --disable $SNAP_INSTANCE_NAME.ovn-northd snapctl stop --disable $SNAP_INSTANCE_NAME.ovn-northd
snapctl stop --disable $SNAP_INSTANCE_NAME.ovn-controller snapctl stop --disable $SNAP_INSTANCE_NAME.ovn-controller
snapctl stop --disable $SNAP_INSTANCE_NAME.rabbitmq-server
snapctl stop --disable $SNAP_INSTANCE_NAME.mysqld
snapctl stop --disable $SNAP_INSTANCE_NAME.iscsid snapctl stop --disable $SNAP_INSTANCE_NAME.iscsid
snapctl stop --disable $SNAP_INSTANCE_NAME.target snapctl stop --disable $SNAP_INSTANCE_NAME.target

View File

@ -29,7 +29,7 @@ from os import path
from init import shell from init import shell
from init.shell import (check, call, check_output, sql, nc_wait, log_wait, from init.shell import (check, call, check_output, sql, nc_wait, log_wait,
start, restart, download, disable, enable) restart, download, disable, enable)
from init.config import Env, log from init.config import Env, log
from init import cluster_tls from init import cluster_tls
from init.questions.question import Question from init.questions.question import Question
@ -327,7 +327,7 @@ class RabbitMq(Question):
config_key = 'config.services.control-plane' config_key = 'config.services.control-plane'
def _wait(self) -> None: def _wait(self) -> None:
restart('rabbitmq-server') # Restart server for plugs enable('rabbitmq-server')
rabbit_port = check_output( rabbit_port = check_output(
'snapctl', 'get', 'config.network.ports.rabbit') 'snapctl', 'get', 'config.network.ports.rabbit')
nc_wait(_env['control_ip'], rabbit_port) nc_wait(_env['control_ip'], rabbit_port)
@ -362,6 +362,7 @@ class DatabaseSetup(Question):
config_key = 'config.services.control-plane' config_key = 'config.services.control-plane'
def _wait(self) -> None: def _wait(self) -> None:
enable('mysqld')
mysql_port = check_output( mysql_port = check_output(
'snapctl', 'get', 'config.network.ports.mysql') 'snapctl', 'get', 'config.network.ports.mysql')
nc_wait(_env['control_ip'], mysql_port) nc_wait(_env['control_ip'], mysql_port)
@ -416,10 +417,7 @@ class DatabaseSetup(Question):
check('snapctl', 'set', 'database.ready=true') check('snapctl', 'set', 'database.ready=true')
# Start keystone-uwsgi. We use snapctl, because systemd enable('nginx')
# doesn't yet know about the service.
start('nginx')
start('keystone-uwsgi')
log.info('Configuring Keystone Fernet Keys ...') log.info('Configuring Keystone Fernet Keys ...')
check('snap-openstack', 'launch', 'keystone-manage', check('snap-openstack', 'launch', 'keystone-manage',
@ -427,7 +425,7 @@ class DatabaseSetup(Question):
'--keystone-group', 'root') '--keystone-group', 'root')
check('snap-openstack', 'launch', 'keystone-manage', 'db_sync') check('snap-openstack', 'launch', 'keystone-manage', 'db_sync')
restart('keystone-uwsgi') enable('keystone-uwsgi')
log.info('Bootstrapping Keystone ...') log.info('Bootstrapping Keystone ...')
self._bootstrap() self._bootstrap()
@ -456,10 +454,14 @@ class NovaHypervisor(Question):
def yes(self, answer): def yes(self, answer):
log.info('Configuring nova compute hypervisor ...') log.info('Configuring nova compute hypervisor ...')
start('nova-compute') enable('libvirtd')
enable('virtlogd')
enable('nova-compute')
def no(self, answer): def no(self, answer):
log.info('Disabling nova compute service ...') log.info('Disabling nova compute service ...')
disable('libvirtd')
disable('virtlogd')
disable('nova-compute') disable('nova-compute')
@ -471,7 +473,7 @@ class NovaSpiceConsoleSetup(Question):
def yes(self, answer): def yes(self, answer):
log.info('Configuring the Spice HTML5 console service...') log.info('Configuring the Spice HTML5 console service...')
start('nova-spicehtml5proxy') enable('nova-spicehtml5proxy')
def no(self, answer): def no(self, answer):
log.info('Disabling nova compute service ...') log.info('Disabling nova compute service ...')
@ -507,12 +509,9 @@ class PlacementSetup(Question):
'microstack', 'placement', endpoint, 'microstack', 'placement', endpoint,
'http://{control_ip}:8778'.format(**_env)) 'http://{control_ip}:8778'.format(**_env))
start('placement-uwsgi')
log.info('Running Placement DB migrations...') log.info('Running Placement DB migrations...')
check('snap-openstack', 'launch', 'placement-manage', 'db', 'sync') check('snap-openstack', 'launch', 'placement-manage', 'db', 'sync')
enable('placement-uwsgi')
restart('placement-uwsgi')
def no(self, answer): def no(self, answer):
log.info('Disabling the Placement service...') log.info('Disabling the Placement service...')
@ -562,12 +561,6 @@ class NovaControlPlane(Question):
check('openstack', 'role', 'add', '--project', check('openstack', 'role', 'add', '--project',
'service', '--user', 'nova', 'reader') 'service', '--user', 'nova', 'reader')
# Use snapctl to start nova services. We need to call them
# out manually, because systemd doesn't know about them yet.
# TODO: parse the output of `snapctl services` to get this
# list automagically.
start('nova-api')
log.info('Running Nova API DB migrations' log.info('Running Nova API DB migrations'
' (this may take a lot of time)...') ' (this may take a lot of time)...')
check('snap-openstack', 'launch', 'nova-manage', 'api_db', 'sync') check('snap-openstack', 'launch', 'nova-manage', 'api_db', 'sync')
@ -588,7 +581,7 @@ class NovaControlPlane(Question):
' (this may take a lot of time)...') ' (this may take a lot of time)...')
check('snap-openstack', 'launch', 'nova-manage', 'db', 'sync') check('snap-openstack', 'launch', 'nova-manage', 'db', 'sync')
restart('nova-api') enable('nova-api')
restart('nova-compute') restart('nova-compute')
for service in [ for service in [
@ -596,7 +589,7 @@ class NovaControlPlane(Question):
'nova-conductor', 'nova-conductor',
'nova-scheduler', 'nova-scheduler',
]: ]:
start(service) enable(service)
nc_wait(_env['compute_ip'], '8774') nc_wait(_env['compute_ip'], '8774')
@ -663,13 +656,11 @@ class CinderSetup(Question):
f'http://{control_ip}:8776/{api_version}/' f'http://{control_ip}:8776/{api_version}/'
'$(project_id)s' '$(project_id)s'
) )
restart('cinder-uwsgi')
log.info('Running Cinder DB migrations...') log.info('Running Cinder DB migrations...')
check('snap-openstack', 'launch', 'cinder-manage', 'db', 'sync') check('snap-openstack', 'launch', 'cinder-manage', 'db', 'sync')
restart('cinder-uwsgi') enable('cinder-uwsgi')
restart('cinder-scheduler') enable('cinder-scheduler')
def no(self, answer): def no(self, answer):
log.info('Disabling Cinder services...') log.info('Disabling Cinder services...')
@ -736,16 +727,10 @@ class NeutronControlPlane(Question):
'microstack', 'network', endpoint, 'microstack', 'network', endpoint,
'http://{control_ip}:9696'.format(**_env)) 'http://{control_ip}:9696'.format(**_env))
start('neutron-api')
check('snap-openstack', 'launch', 'neutron-db-manage', 'upgrade', check('snap-openstack', 'launch', 'neutron-db-manage', 'upgrade',
'head') 'head')
enable('neutron-api')
for service in [ enable('neutron-ovn-metadata-agent')
'neutron-api',
'neutron-ovn-metadata-agent',
]:
restart(service)
nc_wait(_env['control_ip'], '9696') nc_wait(_env['control_ip'], '9696')
@ -852,16 +837,14 @@ class GlanceSetup(Question):
'microstack', 'image', endpoint, 'microstack', 'image', endpoint,
'http://{compute_ip}:9292'.format(**_env)) 'http://{compute_ip}:9292'.format(**_env))
check('snap-openstack', 'launch', 'glance-manage', 'db_sync')
# TODO: remove the glance registry
# https://blueprints.launchpad.net/glance/+spec/deprecate-registry
for service in [ for service in [
'glance-api', 'glance-api',
'registry', # TODO rename to glance-registery 'registry',
]: ]:
start(service) enable(service)
check('snap-openstack', 'launch', 'glance-manage', 'db_sync')
restart('glance-api')
restart('registry')
nc_wait(_env['compute_ip'], '9292') nc_wait(_env['compute_ip'], '9292')
@ -925,7 +908,7 @@ class PostSetup(Question):
# database readiness and hence the clustering service is enabled # database readiness and hence the clustering service is enabled
# and started here. There needs to be a better way to do this. # and started here. There needs to be a better way to do this.
enable('cluster-uwsgi') enable('cluster-uwsgi')
restart('horizon-uwsgi') enable('horizon-uwsgi')
check('snapctl', 'set', 'initialized=true') check('snapctl', 'set', 'initialized=true')
log.info('Complete. Marked microstack as initialized!') log.info('Complete. Marked microstack as initialized!')