Update pre-install hooks to fail on error

The pre-install operations may fail, yet that failure is not
elevated to the user. This masks the failure and makes early
package install issues difficult to troubleshoot.

If the basic pre-install script fails, the charm should not
proceed to later hooks as the requirements may not be met.

Hashbangs for bash should specify -e (errexit) on all of the
pre-install bash scripts.

Change-Id: I40fedc011933cbce6215dd124019d251b6dafd61
Closes-bug: #1815243
Partial-bug: #1815231
This commit is contained in:
Ryan Beisner 2019-02-08 15:46:55 -06:00 committed by David Ames
parent b20b74c5ce
commit 058cd81d40
2 changed files with 28 additions and 3 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash -e
declare -a DEPS=('apt') declare -a DEPS=('apt')

View File

@ -45,8 +45,12 @@ class CeiloAgentBasicDeployment(OpenStackAmuletDeployment):
self._deploy() self._deploy()
u.log.info('Waiting on extended status checks...') u.log.info('Waiting on extended status checks...')
exclude_services = ['mongodb', 'memcached'] self.exclude_services = ['mongodb', 'memcached']
self._auto_wait_for_status(exclude_services=exclude_services) if self._get_openstack_release() >= self.xenial_pike:
# Ceilometer will come up blocked until the ceilometer-upgrade
# action is run
self.exclude_services.append("ceilometer")
self._auto_wait_for_status(exclude_services=self.exclude_services)
self.d.sentry.wait() self.d.sentry.wait()
self._initialize_tests() self._initialize_tests()
@ -175,6 +179,7 @@ class CeiloAgentBasicDeployment(OpenStackAmuletDeployment):
self.log.debug('Instantiating ceilometer client...') self.log.debug('Instantiating ceilometer client...')
if self._get_openstack_release() >= self.xenial_pike: if self._get_openstack_release() >= self.xenial_pike:
self.run_ceilometer_upgrade_action()
self.ceil = ceilo_client.Client(session=self.keystone_session,) self.ceil = ceilo_client.Client(session=self.keystone_session,)
else: else:
# Authenticate admin with ceilometer endpoint # Authenticate admin with ceilometer endpoint
@ -858,3 +863,23 @@ class CeiloAgentBasicDeployment(OpenStackAmuletDeployment):
u.log.debug('Checking for active status on {}'.format(unit_name)) u.log.debug('Checking for active status on {}'.format(unit_name))
assert u.status_get(unit)[0] == "active" assert u.status_get(unit)[0] == "active"
u.log.debug('OK') u.log.debug('OK')
def run_ceilometer_upgrade_action(self):
"""Run ceilometer-upgrade
This action will be run early to initialize ceilometer
when gnocchi is related.
Ceilometer will be in a blocked state until this runs.
"""
if self._get_openstack_release() < self.xenial_pike:
u.log.debug('Not checking ceilometer-upgrade')
return
u.log.debug('Checking ceilometer-upgrade')
unit = self.ceil_sentry
action_id = unit.run_action("ceilometer-upgrade")
assert u.wait_on_action(action_id), "ceilometer-upgrade action failed"
# Wait for acivte Unit is ready on ceilometer
self.exclude_services.remove('ceilometer')
self._auto_wait_for_status(exclude_services=self.exclude_services)
u.log.debug('OK')