Take control of when `ceph-create-keys` is run

For Ceph versions prior to Luminous the `ceph-create-keys`
is run by the init system in conjunction with starting the
ceph-mon service.

At some point during the Hammer lifetime a hard coded timeout
of 600 seconds was added:
8bab74537f

In many circumstances this is not enough.  With this commit
we take control of running this command.

__NOTE__ it is important that charms deploying the ceph-mon
disable running of `ceph-create-keys` from the init system.

From Luminous and onwards we can use the newly added --timeout
flag.  For previous versions we rely on retry_on_exception
decorator.

Change-Id: I3d3c7298076730c423ca5cc059316619f415b885
Related-Bug: #1719436
This commit is contained in:
Frode Nordahl 2018-05-08 12:39:49 +02:00
parent e30e572902
commit 94b489949d
No known key found for this signature in database
GPG Key ID: 6A5D59A3BA48373F
1 changed files with 18 additions and 8 deletions

View File

@ -1364,17 +1364,27 @@ def add_keyring_to_ceph(keyring, secret, hostname, path, done, init_marker):
else:
service_restart('ceph-mon-all')
# NOTE(jamespage): Later ceph releases require explicit
# call to ceph-create-keys to setup the
# admin keys for the cluster; this command
# will wait for quorum in the cluster before
# returning.
# NOTE(fnordahl): Explicitly run `ceph-crate-keys` for older
# ceph releases too. This improves bootstrap
# resilience as the charm will wait for
# presence of peer units before attempting
# to bootstrap. Note that charms deploying
# ceph-mon service should disable running of
# `ceph-create-keys` service in init system.
cmd = ['ceph-create-keys', '--id', hostname]
if cmp_pkgrevno('ceph', '12.0.0') >= 0:
# NOTE(jamespage): Later ceph releases require explicit
# call to ceph-create-keys to setup the
# admin keys for the cluster; this command
# will wait for quorum in the cluster before
# returning.
# NOTE(fnordahl): The default timeout in ceph-create-keys of 600
# seconds is not adequate for all situations.
# seconds is not adequate. Increase timeout when
# timeout parameter available. For older releases
# we rely on retry_on_exception decorator.
# LP#1719436
cmd = ['ceph-create-keys', '--id', hostname, '--timeout', '1800']
subprocess.check_call(cmd)
cmd.extend(['--timeout', '1800'])
subprocess.check_call(cmd)
_client_admin_keyring = '/etc/ceph/ceph.client.admin.keyring'
osstat = os.stat(_client_admin_keyring)
if not osstat.st_size: