Merge lp:~peter-sabaini/charms/trusty/ceph-osd/ceph-osd-multijournal-next into lp:~openstack-charmers-archive/charms/trusty/ceph-osd/next

Proposed by Peter Sabaini
Status: Rejected
Rejected by: James Page
Proposed branch: lp:~peter-sabaini/charms/trusty/ceph-osd/ceph-osd-multijournal-next
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceph-osd/next
Diff against target: 207 lines (+84/-19) (has conflicts)
2 files modified
hooks/ceph.py (+39/-7)
hooks/ceph_hooks.py (+45/-12)
Text conflict in hooks/ceph.py
To merge this branch: bzr merge lp:~peter-sabaini/charms/trusty/ceph-osd/ceph-osd-multijournal-next
Reviewer Review Type Date Requested Status
James Page Needs Fixing
Chris Holcombe (community) Approve
Review via email: mp+281149@code.launchpad.net

Description of the change

  * Handle multiple journals

  * Select least-used journal disk instead of blind RR

  * Add safeguard for OSD journals

  * Avoid zapping journals repeatedly, add check for journal partition type

  * Check that journal devices don't overlap with data devices

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #14718 ceph-osd-next for peter-sabaini mp281149
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/14718/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #15770 ceph-osd-next for peter-sabaini mp281149
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: pastebin not avail., cmd error
Build: http://10.245.162.77:8080/job/charm_lint_check/15770/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #8384 ceph-osd-next for peter-sabaini mp281149
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/8384/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #16579 ceph-osd-next for peter-sabaini mp281149
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/14407597/
Build: http://10.245.162.77:8080/job/charm_lint_check/16579/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #15488 ceph-osd-next for peter-sabaini mp281149
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/15488/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #8504 ceph-osd-next for peter-sabaini mp281149
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/8504/

Revision history for this message
Chris Holcombe (xfactor973) :
Revision history for this message
Chris Holcombe (xfactor973) wrote :

If you could just change that write over to being atomic I think this is good to go. I've love to deploy it to aws to test it.

review: Needs Fixing
Revision history for this message
Peter Sabaini (peter-sabaini) wrote :

Thanks for the review and the suggestion around the atomic write, will update!

Revision history for this message
Chris MacNaughton (chris.macnaughton) wrote :

Hey Peter, this looks great and I look forward to t hat change! If we want to get this landed for the 16.01 feature freeze, we need that change in soon!

Thanks again!

56. By Peter Sabaini

Make writing the zapfile safer

Revision history for this message
Peter Sabaini (peter-sabaini) wrote :

Heya Chris+Chris, hope that was what you were looking for?

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #17945 ceph-osd-next for peter-sabaini mp281149
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/14598402/
Build: http://10.245.162.77:8080/job/charm_lint_check/17945/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #16770 ceph-osd-next for peter-sabaini mp281149
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/16770/

Revision history for this message
Chris Holcombe (xfactor973) wrote :

Yes that's perfect. Thanks!

review: Approve
Revision history for this message
Chris Holcombe (xfactor973) wrote :

Peter Sabaini - If you could rebase and take care of that merge conflict we can land this :)

Revision history for this message
James Page (james-page) wrote :

Note that the lint on the python code also needs resolving:

hooks/ceph_hooks.py:108:1: E302 expected 2 blank lines, found 1
hooks/ceph_hooks.py:118:1: E302 expected 2 blank lines, found 1
hooks/ceph_hooks.py:126:1: E302 expected 2 blank lines, found 1
hooks/ceph_hooks.py:128:80: E501 line too long (85 > 79 characters)
hooks/ceph_hooks.py:133:1: E302 expected 2 blank lines, found 1
hooks/ceph_hooks.py:152:1: E302 expected 2 blank lines, found 1
hooks/ceph_hooks.py:217:1: E302 expected 2 blank lines, found 1
hooks/ceph_hooks.py:225:1: E302 expected 2 blank lines, found 1
hooks/ceph.py:113:44: E261 at least two spaces before inline comment
hooks/ceph.py:114:44: E261 at least two spaces before inline comment
hooks/ceph.py:115:5: E123 closing bracket does not match indentation of opening bracket's line
hooks/ceph.py:117:1: E302 expected 2 blank lines, found 1
hooks/ceph.py:314:1: E302 expected 2 blank lines, found 1
hooks/ceph.py:316:80: E501 line too long (80 > 79 characters)
hooks/ceph.py:322:1: E302 expected 2 blank lines, found 1
hooks/ceph.py:332:1: E302 expected 2 blank lines, found 1
hooks/ceph.py:337:1: E302 expected 2 blank lines, found 1
hooks/ceph.py:356:80: E501 line too long (85 > 79 characters)

Peter - do you have time to make these changes?

review: Needs Fixing
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #17028 ceph-osd-next for peter-sabaini mp281149
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/17028/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #18277 ceph-osd-next for peter-sabaini mp281149
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/14691030/
Build: http://10.245.162.77:8080/job/charm_lint_check/18277/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #9094 ceph-osd-next for peter-sabaini mp281149
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/14692078/
Build: http://10.245.162.77:8080/job/charm_amulet_test/9094/

Revision history for this message
James Page (james-page) wrote :

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/ceph.py'
--- hooks/ceph.py 2016-01-12 14:16:54 +0000
+++ hooks/ceph.py 2016-01-22 15:57:27 +0000
@@ -22,9 +22,13 @@
22)22)
23from charmhelpers.core.hookenv import (23from charmhelpers.core.hookenv import (
24 log,24 log,
25<<<<<<< TREE
25 ERROR,26 ERROR,
26 WARNING,27 WARNING,
27 cached,28 cached,
29=======
30 ERROR, WARNING, DEBUG,
31>>>>>>> MERGE-SOURCE
28 status_set,32 status_set,
29)33)
30from charmhelpers.fetch import (34from charmhelpers.fetch import (
@@ -170,16 +174,20 @@
170 'btrfs'174 'btrfs'
171]175]
172176
177CEPH_PARTITIONS = [
178 '4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D', # ceph osd data
179 '45B0969E-9B03-4F30-B4C6-B4B80CEFF106', # ceph osd journal
180 ]
173181
174def is_osd_disk(dev):182def is_osd_disk(dev):
175 try:183 try:
176 info = subprocess.check_output(['sgdisk', '-i', '1', dev])184 info = subprocess.check_output(['sgdisk', '-i', '1', dev])
177 info = info.split("\n") # IGNORE:E1103185 info = info.split("\n") # IGNORE:E1103
178 for line in info:186 for line in info:
179 if line.startswith(187 for ptype in CEPH_PARTITIONS:
180 'Partition GUID code: 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D'188 sig = 'Partition GUID code: {}'.format(ptype)
181 ):189 if line.startswith(sig):
182 return True190 return True
183 except subprocess.CalledProcessError:191 except subprocess.CalledProcessError:
184 pass192 pass
185 return False193 return False
@@ -394,6 +402,28 @@
394 with open(init_marker, 'w'):402 with open(init_marker, 'w'):
395 pass403 pass
396404
405def maybe_zap_journal(journal_dev):
406 if (is_osd_disk(journal_dev)):
407 log('Looks like {} is already an OSD data or journal, skipping.'.format(
408 journal_dev))
409 return
410 zap_disk(journal_dev)
411 log("Zapped journal device {}".format(journal_dev))
412
413def get_partitions(dev):
414 cmd = ['partx', '--raw', '--noheadings', dev]
415 try:
416 out = subprocess.check_output(cmd).splitlines()
417 log("get partitions: {}".format(out), level=DEBUG)
418 return out
419 except subprocess.CalledProcessError as e:
420 log("Can't get info for {0}: {1}".format(dev, e.output))
421 return []
422
423def find_least_used_journal(journal_devices):
424 usages = map(lambda a: (len(get_partitions(a)), a), journal_devices)
425 least = min(usages, key=lambda t: t[0])
426 return least[1]
397427
398def osdize(dev, osd_format, osd_journal, reformat_osd=False,428def osdize(dev, osd_format, osd_journal, reformat_osd=False,
399 ignore_errors=False):429 ignore_errors=False):
@@ -414,7 +444,7 @@
414 return444 return
415445
416 if (is_osd_disk(dev) and not reformat_osd):446 if (is_osd_disk(dev) and not reformat_osd):
417 log('Looks like {} is already an OSD, skipping.'.format(dev))447 log('Looks like {} is already an OSD data or journal, skipping.'.format(dev))
418 return448 return
419449
420 if is_device_mounted(dev):450 if is_device_mounted(dev):
@@ -431,8 +461,9 @@
431 if reformat_osd:461 if reformat_osd:
432 cmd.append('--zap-disk')462 cmd.append('--zap-disk')
433 cmd.append(dev)463 cmd.append(dev)
434 if osd_journal and os.path.exists(osd_journal):464 if osd_journal:
435 cmd.append(osd_journal)465 least_used = find_least_used_journal(osd_journal)
466 cmd.append(least_used)
436 else:467 else:
437 # Just provide the device - no other options468 # Just provide the device - no other options
438 # for older versions of ceph469 # for older versions of ceph
@@ -441,6 +472,7 @@
441 zap_disk(dev)472 zap_disk(dev)
442473
443 try:474 try:
475 log("osdize cmd: {}".format(cmd))
444 subprocess.check_call(cmd)476 subprocess.check_call(cmd)
445 except subprocess.CalledProcessError as e:477 except subprocess.CalledProcessError as e:
446 if ignore_errors:478 if ignore_errors:
447479
=== modified file 'hooks/ceph_hooks.py'
--- hooks/ceph_hooks.py 2016-01-18 10:17:06 +0000
+++ hooks/ceph_hooks.py 2016-01-22 15:57:27 +0000
@@ -11,11 +11,13 @@
11import os11import os
12import shutil12import shutil
13import sys13import sys
14import tempfile
1415
15import ceph16import ceph
16from charmhelpers.core.hookenv import (17from charmhelpers.core.hookenv import (
17 log,18 log,
18 ERROR,19 ERROR,
20 DEBUG,
19 config,21 config,
20 relation_ids,22 relation_ids,
21 related_units,23 related_units,
@@ -105,6 +107,30 @@
105107
106JOURNAL_ZAPPED = '/var/lib/ceph/journal_zapped'108JOURNAL_ZAPPED = '/var/lib/ceph/journal_zapped'
107109
110def read_zapped_journals():
111 if os.path.exists(JOURNAL_ZAPPED):
112 with open(JOURNAL_ZAPPED) as zapfile:
113 zapped = set(
114 filter(None,
115 [l.strip() for l in zapfile.readlines()]))
116 log("read zapped: {}".format(zapped), level=DEBUG)
117 return zapped
118 return set()
119
120def write_zapped_journals(journal_devs):
121 tmpfh, tmpfile = tempfile.mkstemp()
122 with os.fdopen(tmpfh, 'wb') as zapfile:
123 log("write zapped: {}".format(journal_devs),
124 level=DEBUG)
125 zapfile.write('\n'.join(sorted(list(journal_devs))))
126 os.rename(tmpfile, JOURNAL_ZAPPED)
127
128def check_overlap(journaldevs, datadevs):
129 if not journaldevs.isdisjoint(datadevs):
130 msg = "Journal/data devices mustn't overlap; journal: {0}, data: {1}".format(
131 journaldevs, datadevs)
132 log(msg, level=ERROR)
133 raise ValueError(msg)
108134
109@hooks.hook('config-changed')135@hooks.hook('config-changed')
110def config_changed():136def config_changed():
@@ -123,20 +149,24 @@
123 e_mountpoint = config('ephemeral-unmount')149 e_mountpoint = config('ephemeral-unmount')
124 if (e_mountpoint and ceph.filesystem_mounted(e_mountpoint)):150 if (e_mountpoint and ceph.filesystem_mounted(e_mountpoint)):
125 umount(e_mountpoint)151 umount(e_mountpoint)
152 prepare_disks_and_activate()
126153
127 osd_journal = config('osd-journal')154def prepare_disks_and_activate():
128 if (osd_journal and not os.path.exists(JOURNAL_ZAPPED) and155 osd_journal = get_journal_devices()
129 os.path.exists(osd_journal)):156 check_overlap(osd_journal, set(get_devices()))
130 ceph.zap_disk(osd_journal)157 log("got journal devs: {}".format(osd_journal), level=DEBUG)
131 with open(JOURNAL_ZAPPED, 'w') as zapped:158 already_zapped = read_zapped_journals()
132 zapped.write('DONE')159 non_zapped = osd_journal - already_zapped
160 for journ in non_zapped:
161 ceph.maybe_zap_journal(journ)
162 write_zapped_journals(osd_journal)
133163
134 if ceph.is_bootstrapped():164 if ceph.is_bootstrapped():
135 log('ceph bootstrapped, rescanning disks')165 log('ceph bootstrapped, rescanning disks')
136 emit_cephconf()166 emit_cephconf()
137 for dev in get_devices():167 for dev in get_devices():
138 ceph.osdize(dev, config('osd-format'),168 ceph.osdize(dev, config('osd-format'),
139 config('osd-journal'), config('osd-reformat'),169 osd_journal, config('osd-reformat'),
140 config('ignore-device-errors'))170 config('ignore-device-errors'))
141 ceph.start_osds(get_devices())171 ceph.start_osds(get_devices())
142172
@@ -186,6 +216,13 @@
186 else:216 else:
187 return []217 return []
188218
219def get_journal_devices():
220 osd_journal = config('osd-journal')
221 if not osd_journal:
222 return set()
223 osd_journal = [l.strip() for l in config('osd-journal').split(' ')]
224 osd_journal = set(filter(os.path.exists, osd_journal))
225 return osd_journal
189226
190@hooks.hook('mon-relation-changed',227@hooks.hook('mon-relation-changed',
191 'mon-relation-departed')228 'mon-relation-departed')
@@ -195,11 +232,7 @@
195 log('mon has provided conf- scanning disks')232 log('mon has provided conf- scanning disks')
196 emit_cephconf()233 emit_cephconf()
197 ceph.import_osd_bootstrap_key(bootstrap_key)234 ceph.import_osd_bootstrap_key(bootstrap_key)
198 for dev in get_devices():235 prepare_disks_and_activate()
199 ceph.osdize(dev, config('osd-format'),
200 config('osd-journal'), config('osd-reformat'),
201 config('ignore-device-errors'))
202 ceph.start_osds(get_devices())
203 else:236 else:
204 log('mon cluster has not yet provided conf')237 log('mon cluster has not yet provided conf')
205238

Subscribers

People subscribed via source and target branches