~openstack-charmers-next/charms/vivid/openstack-dashboard/trunk

« back to all changes in this revision

Viewing changes to hooks/horizon_hooks.py

  • Committer: David Ames
  • Date: 2016-03-08 15:56:41 UTC
  • Revision ID: david.ames@canonical.com-20160308155641-ykzhphmsqhhhl907
Add sleep between stop/start in restart_on_change

When restart_on_change runs service restart apache is not waiting for
its threads to terminate particularly due to WSGI being involved for
openstack-dashboard. When it attempts to restart the ports are already
in use and unavailable. This change works around this bug adding a sleep
time between stop and start to allow apache time to terminate its
threads.

Closes-Bug: #1545217
Related-Bug: #1552822

Change-Id: Ib5d4dee9a001b4554191abfdc7577ef739efd0f2

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
)
20
20
from charmhelpers.core.host import (
21
21
    lsb_release,
22
 
    restart_on_change
23
22
)
24
23
from charmhelpers.contrib.openstack.utils import (
25
24
    config_value_changed,
44
43
    setup_ipv6,
45
44
    INSTALL_DIR,
46
45
    REQUIRED_INTERFACES,
 
46
    restart_on_change
47
47
)
48
48
from charmhelpers.contrib.network.ip import (
49
49
    get_iface_for_address,
82
82
 
83
83
 
84
84
@hooks.hook('upgrade-charm')
85
 
@restart_on_change(restart_map())
 
85
@restart_on_change(restart_map(), stopstart=True, sleep=3)
86
86
def upgrade_charm():
87
87
    execd_preinstall()
88
88
    apt_install(filter_installed_packages(determine_packages()), fatal=True)
91
91
 
92
92
 
93
93
@hooks.hook('config-changed')
94
 
@restart_on_change(restart_map())
 
94
@restart_on_change(restart_map(), stopstart=True, sleep=3)
95
95
def config_changed():
96
96
    if config('prefer-ipv6'):
97
97
        setup_ipv6()
149
149
 
150
150
 
151
151
@hooks.hook('identity-service-relation-changed')
152
 
@restart_on_change(restart_map())
 
152
@restart_on_change(restart_map(), stopstart=True, sleep=3)
153
153
def keystone_changed():
154
154
    CONFIGS.write(LOCAL_SETTINGS)
155
155
    if relation_get('ca_cert'):
166
166
 
167
167
@hooks.hook('cluster-relation-departed',
168
168
            'cluster-relation-changed')
169
 
@restart_on_change(restart_map())
 
169
@restart_on_change(restart_map(), stopstart=True, sleep=3)
170
170
def cluster_relation():
171
171
    CONFIGS.write(HAPROXY_CONF)
172
172
 
266
266
 
267
267
 
268
268
@hooks.hook('dashboard-plugin-relation-changed')
269
 
@restart_on_change(restart_map())
 
269
@restart_on_change(restart_map(), stopstart=True, sleep=3)
270
270
def update_plugin_config():
271
271
    CONFIGS.write(LOCAL_SETTINGS)
272
272