Merge lp:~ahasenack/charms/precise/rabbitmq-server/check-device-before-mkfs into lp:charms/rabbitmq-server

Proposed by Andreas Hasenack
Status: Merged
Approved by: Adam Gandelman
Approved revision: 47
Merged at revision: 43
Proposed branch: lp:~ahasenack/charms/precise/rabbitmq-server/check-device-before-mkfs
Merge into: lp:charms/rabbitmq-server
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/rabbitmq-server/check-device-before-mkfs
Reviewer Review Type Date Requested Status
Adam Gandelman (community) Approve
Review via email: mp+179282@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
=== modified file 'hooks/lib/ceph_utils.py'
--- hooks/lib/ceph_utils.py 2013-03-18 10:28:17 +0000
+++ hooks/lib/ceph_utils.py 2013-08-08 21:24:23 +0000
@@ -12,6 +12,7 @@
12import subprocess12import subprocess
13import os13import os
14import shutil14import shutil
15import time
15import lib.utils as utils16import lib.utils as utils
1617
17KEYRING = '/etc/ceph/ceph.client.%s.keyring'18KEYRING = '/etc/ceph/ceph.client.%s.keyring'
@@ -153,11 +154,22 @@
153154
154155
155def make_filesystem(blk_device, fstype='ext4'):156def make_filesystem(blk_device, fstype='ext4'):
156 utils.juju_log('INFO',157 count = 0
157 'ceph: Formatting block device %s as filesystem %s.' %\158 e_noent = os.errno.ENOENT
158 (blk_device, fstype))159 while not os.path.exists(blk_device):
159 cmd = ['mkfs', '-t', fstype, blk_device]160 if count >= 10:
160 execute(cmd)161 utils.juju_log('ERROR',
162 'ceph: gave up waiting on block device %s' % blk_device)
163 raise IOError(e_noent, os.strerror(e_noent), blk_device)
164 utils.juju_log('INFO',
165 'ceph: waiting for block device %s to appear' % blk_device)
166 count += 1
167 time.sleep(1)
168 else:
169 utils.juju_log('INFO',
170 'ceph: Formatting block device %s as filesystem %s.' %
171 (blk_device, fstype))
172 execute(['mkfs', '-t', fstype, blk_device])
161173
162174
163def place_data_on_ceph(service, blk_device, data_src_dst, fstype='ext4'):175def place_data_on_ceph(service, blk_device, data_src_dst, fstype='ext4'):
164176
=== modified file 'revision'
--- revision 2013-07-26 22:31:07 +0000
+++ revision 2013-08-08 21:24:23 +0000
@@ -1,1 +1,1 @@
196197

Subscribers

People subscribed via source and target branches