~openstack-charmers/charms/trusty/neutron-gateway/next

« back to all changes in this revision

Viewing changes to hooks/neutron_utils.py

  • Committer: James Page
  • Date: 2016-07-12 12:02:39 UTC
  • Revision ID: james.page@ubuntu.com-20160712120239-lyvesld5221u05s9
Avoid restart races for nova-api-metadata

It's possible that the nova-api-metadata will startup during the
time that the nova-conductor processes on the nova-cloud-controller
units are still starting up, resulting in a messaging timeout which
causes the daemon to exit 0.

Upstart will restart a service in this scenario, however systemd is
configured in packaging to only restart 'on-failure' so will not
attempt to restart.

This points to two other bugs - one that a messaging timeout results
in a exit code of 0, and that the OpenStack services under systemd
behave differently to under upstart.

Install an override file for systemd based installs to mimic the
behaviour of upstart, and deal with a code logic problem in the
restart_trigger handling to ensure that the charm does at least
try to restart the nova-api-metadata service at the right points
in time.

Change-Id: Ia08b7840efa33fd301d0e2c55bb30ae1a102cbfa
Closes-Bug: 1547122

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
    service_stop,
14
14
    service_restart,
15
15
    write_file,
 
16
    init_is_systemd,
16
17
)
17
18
from charmhelpers.core.hookenv import (
18
19
    charm_dir,
478
479
}
479
480
 
480
481
 
 
482
# Override file for systemd
 
483
SYSTEMD_NOVA_OVERRIDE = (
 
484
    '/etc/systemd/system/nova-api-metadata.service.d/override.conf'
 
485
)
 
486
 
 
487
 
 
488
def install_systemd_override():
 
489
    '''
 
490
    Install systemd override files for nova-api-metadata
 
491
    and reload systemd daemon if required.
 
492
    '''
 
493
    if init_is_systemd() and not os.path.exists(SYSTEMD_NOVA_OVERRIDE):
 
494
        mkdir(os.path.dirname(SYSTEMD_NOVA_OVERRIDE))
 
495
        shutil.copy(os.path.join('files',
 
496
                                 os.path.basename(SYSTEMD_NOVA_OVERRIDE)),
 
497
                    SYSTEMD_NOVA_OVERRIDE)
 
498
        subprocess.check_call(['systemctl', 'daemon-reload'])
 
499
 
 
500
 
481
501
def remap_service(service_name):
482
502
    '''
483
503
    Remap service names based on openstack release to deal