Merge lp:~ahasenack/charms/precise/mysql/wait-for-rbd-device into lp:charms/mysql

Proposed by Andreas Hasenack
Status: Merged
Approved by: Adam Gandelman
Approved revision: 104
Merged at revision: 104
Proposed branch: lp:~ahasenack/charms/precise/mysql/wait-for-rbd-device
Merge into: lp:charms/mysql
Diff against target: 46 lines (+18/-6)
2 files modified
hooks/lib/ceph_utils.py (+17/-5)
revision (+1/-1)
To merge this branch: bzr merge lp:~ahasenack/charms/precise/mysql/wait-for-rbd-device
Reviewer Review Type Date Requested Status
Adam Gandelman (community) Approve
Review via email: mp+179292@code.launchpad.net

Description of the change

Check for the existence of the rbd device before attempting to format it. If it doesn't exist, wait in a loop for up to 10s before failing.

To post a comment you must log in.
Revision history for this message
Adam Gandelman (gandelman-a) wrote :

This looks sane. Can you please also propose the same fix to charm-helpers, as this code now lives there in charmhelpers/contrib/hacluster/ceph.py

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/lib/ceph_utils.py'
2--- hooks/lib/ceph_utils.py 2013-03-16 07:47:51 +0000
3+++ hooks/lib/ceph_utils.py 2013-08-08 21:54:22 +0000
4@@ -12,6 +12,7 @@
5 import subprocess
6 import os
7 import shutil
8+import time
9 import lib.utils as utils
10
11 KEYRING = '/etc/ceph/ceph.client.%s.keyring'
12@@ -153,11 +154,22 @@
13
14
15 def make_filesystem(blk_device, fstype='ext4'):
16- utils.juju_log('INFO',
17- 'ceph: Formatting block device %s as filesystem %s.' %\
18- (blk_device, fstype))
19- cmd = ['mkfs', '-t', fstype, blk_device]
20- execute(cmd)
21+ count = 0
22+ e_noent = os.errno.ENOENT
23+ while not os.path.exists(blk_device):
24+ if count >= 10:
25+ utils.juju_log('ERROR',
26+ 'ceph: gave up waiting on block device %s' % blk_device)
27+ raise IOError(e_noent, os.strerror(e_noent), blk_device)
28+ utils.juju_log('INFO',
29+ 'ceph: waiting for block device %s to appear' % blk_device)
30+ count += 1
31+ time.sleep(1)
32+ else:
33+ utils.juju_log('INFO',
34+ 'ceph: Formatting block device %s as filesystem %s.' %
35+ (blk_device, fstype))
36+ execute(['mkfs', '-t', fstype, blk_device])
37
38
39 def place_data_on_ceph(service, blk_device, data_src_dst, fstype='ext4'):
40
41=== modified file 'revision'
42--- revision 2013-07-23 22:59:11 +0000
43+++ revision 2013-08-08 21:54:22 +0000
44@@ -1,1 +1,1 @@
45-308
46+309

Subscribers

People subscribed via source and target branches