Browse Source

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
changes/48/635948/2
Ryan Beisner 4 months ago
parent
commit
058cd81d40
2 changed files with 28 additions and 3 deletions
  1. 1
    1
      hooks/install
  2. 27
    2
      tests/basic_deployment.py

+ 1
- 1
hooks/install View File

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

+ 27
- 2
tests/basic_deployment.py View File

@@ -45,8 +45,12 @@ class CeiloAgentBasicDeployment(OpenStackAmuletDeployment):
45 45
         self._deploy()
46 46
 
47 47
         u.log.info('Waiting on extended status checks...')
48
-        exclude_services = ['mongodb', 'memcached']
49
-        self._auto_wait_for_status(exclude_services=exclude_services)
48
+        self.exclude_services = ['mongodb', 'memcached']
49
+        if self._get_openstack_release() >= self.xenial_pike:
50
+            # Ceilometer will come up blocked until the ceilometer-upgrade
51
+            # action is run
52
+            self.exclude_services.append("ceilometer")
53
+        self._auto_wait_for_status(exclude_services=self.exclude_services)
50 54
 
51 55
         self.d.sentry.wait()
52 56
         self._initialize_tests()
@@ -175,6 +179,7 @@ class CeiloAgentBasicDeployment(OpenStackAmuletDeployment):
175 179
 
176 180
         self.log.debug('Instantiating ceilometer client...')
177 181
         if self._get_openstack_release() >= self.xenial_pike:
182
+            self.run_ceilometer_upgrade_action()
178 183
             self.ceil = ceilo_client.Client(session=self.keystone_session,)
179 184
         else:
180 185
             # Authenticate admin with ceilometer endpoint
@@ -858,3 +863,23 @@ class CeiloAgentBasicDeployment(OpenStackAmuletDeployment):
858 863
         u.log.debug('Checking for active status on {}'.format(unit_name))
859 864
         assert u.status_get(unit)[0] == "active"
860 865
         u.log.debug('OK')
866
+
867
+    def run_ceilometer_upgrade_action(self):
868
+        """Run ceilometer-upgrade
869
+
870
+        This action will be run early to initialize ceilometer
871
+        when gnocchi is related.
872
+        Ceilometer will be in a blocked state until this runs.
873
+        """
874
+        if self._get_openstack_release() < self.xenial_pike:
875
+            u.log.debug('Not checking ceilometer-upgrade')
876
+            return
877
+        u.log.debug('Checking ceilometer-upgrade')
878
+        unit = self.ceil_sentry
879
+
880
+        action_id = unit.run_action("ceilometer-upgrade")
881
+        assert u.wait_on_action(action_id), "ceilometer-upgrade action failed"
882
+        # Wait for acivte Unit is ready on ceilometer
883
+        self.exclude_services.remove('ceilometer')
884
+        self._auto_wait_for_status(exclude_services=self.exclude_services)
885
+        u.log.debug('OK')

Loading…
Cancel
Save