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
1=== modified file 'hooks/ceph.py'
2--- hooks/ceph.py 2016-01-12 14:16:54 +0000
3+++ hooks/ceph.py 2016-01-22 15:57:27 +0000
4@@ -22,9 +22,13 @@
5 )
6 from charmhelpers.core.hookenv import (
7 log,
8+<<<<<<< TREE
9 ERROR,
10 WARNING,
11 cached,
12+=======
13+ ERROR, WARNING, DEBUG,
14+>>>>>>> MERGE-SOURCE
15 status_set,
16 )
17 from charmhelpers.fetch import (
18@@ -170,16 +174,20 @@
19 'btrfs'
20 ]
21
22+CEPH_PARTITIONS = [
23+ '4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D', # ceph osd data
24+ '45B0969E-9B03-4F30-B4C6-B4B80CEFF106', # ceph osd journal
25+ ]
26
27 def is_osd_disk(dev):
28 try:
29 info = subprocess.check_output(['sgdisk', '-i', '1', dev])
30 info = info.split("\n") # IGNORE:E1103
31 for line in info:
32- if line.startswith(
33- 'Partition GUID code: 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D'
34- ):
35- return True
36+ for ptype in CEPH_PARTITIONS:
37+ sig = 'Partition GUID code: {}'.format(ptype)
38+ if line.startswith(sig):
39+ return True
40 except subprocess.CalledProcessError:
41 pass
42 return False
43@@ -394,6 +402,28 @@
44 with open(init_marker, 'w'):
45 pass
46
47+def maybe_zap_journal(journal_dev):
48+ if (is_osd_disk(journal_dev)):
49+ log('Looks like {} is already an OSD data or journal, skipping.'.format(
50+ journal_dev))
51+ return
52+ zap_disk(journal_dev)
53+ log("Zapped journal device {}".format(journal_dev))
54+
55+def get_partitions(dev):
56+ cmd = ['partx', '--raw', '--noheadings', dev]
57+ try:
58+ out = subprocess.check_output(cmd).splitlines()
59+ log("get partitions: {}".format(out), level=DEBUG)
60+ return out
61+ except subprocess.CalledProcessError as e:
62+ log("Can't get info for {0}: {1}".format(dev, e.output))
63+ return []
64+
65+def find_least_used_journal(journal_devices):
66+ usages = map(lambda a: (len(get_partitions(a)), a), journal_devices)
67+ least = min(usages, key=lambda t: t[0])
68+ return least[1]
69
70 def osdize(dev, osd_format, osd_journal, reformat_osd=False,
71 ignore_errors=False):
72@@ -414,7 +444,7 @@
73 return
74
75 if (is_osd_disk(dev) and not reformat_osd):
76- log('Looks like {} is already an OSD, skipping.'.format(dev))
77+ log('Looks like {} is already an OSD data or journal, skipping.'.format(dev))
78 return
79
80 if is_device_mounted(dev):
81@@ -431,8 +461,9 @@
82 if reformat_osd:
83 cmd.append('--zap-disk')
84 cmd.append(dev)
85- if osd_journal and os.path.exists(osd_journal):
86- cmd.append(osd_journal)
87+ if osd_journal:
88+ least_used = find_least_used_journal(osd_journal)
89+ cmd.append(least_used)
90 else:
91 # Just provide the device - no other options
92 # for older versions of ceph
93@@ -441,6 +472,7 @@
94 zap_disk(dev)
95
96 try:
97+ log("osdize cmd: {}".format(cmd))
98 subprocess.check_call(cmd)
99 except subprocess.CalledProcessError as e:
100 if ignore_errors:
101
102=== modified file 'hooks/ceph_hooks.py'
103--- hooks/ceph_hooks.py 2016-01-18 10:17:06 +0000
104+++ hooks/ceph_hooks.py 2016-01-22 15:57:27 +0000
105@@ -11,11 +11,13 @@
106 import os
107 import shutil
108 import sys
109+import tempfile
110
111 import ceph
112 from charmhelpers.core.hookenv import (
113 log,
114 ERROR,
115+ DEBUG,
116 config,
117 relation_ids,
118 related_units,
119@@ -105,6 +107,30 @@
120
121 JOURNAL_ZAPPED = '/var/lib/ceph/journal_zapped'
122
123+def read_zapped_journals():
124+ if os.path.exists(JOURNAL_ZAPPED):
125+ with open(JOURNAL_ZAPPED) as zapfile:
126+ zapped = set(
127+ filter(None,
128+ [l.strip() for l in zapfile.readlines()]))
129+ log("read zapped: {}".format(zapped), level=DEBUG)
130+ return zapped
131+ return set()
132+
133+def write_zapped_journals(journal_devs):
134+ tmpfh, tmpfile = tempfile.mkstemp()
135+ with os.fdopen(tmpfh, 'wb') as zapfile:
136+ log("write zapped: {}".format(journal_devs),
137+ level=DEBUG)
138+ zapfile.write('\n'.join(sorted(list(journal_devs))))
139+ os.rename(tmpfile, JOURNAL_ZAPPED)
140+
141+def check_overlap(journaldevs, datadevs):
142+ if not journaldevs.isdisjoint(datadevs):
143+ msg = "Journal/data devices mustn't overlap; journal: {0}, data: {1}".format(
144+ journaldevs, datadevs)
145+ log(msg, level=ERROR)
146+ raise ValueError(msg)
147
148 @hooks.hook('config-changed')
149 def config_changed():
150@@ -123,20 +149,24 @@
151 e_mountpoint = config('ephemeral-unmount')
152 if (e_mountpoint and ceph.filesystem_mounted(e_mountpoint)):
153 umount(e_mountpoint)
154+ prepare_disks_and_activate()
155
156- osd_journal = config('osd-journal')
157- if (osd_journal and not os.path.exists(JOURNAL_ZAPPED) and
158- os.path.exists(osd_journal)):
159- ceph.zap_disk(osd_journal)
160- with open(JOURNAL_ZAPPED, 'w') as zapped:
161- zapped.write('DONE')
162+def prepare_disks_and_activate():
163+ osd_journal = get_journal_devices()
164+ check_overlap(osd_journal, set(get_devices()))
165+ log("got journal devs: {}".format(osd_journal), level=DEBUG)
166+ already_zapped = read_zapped_journals()
167+ non_zapped = osd_journal - already_zapped
168+ for journ in non_zapped:
169+ ceph.maybe_zap_journal(journ)
170+ write_zapped_journals(osd_journal)
171
172 if ceph.is_bootstrapped():
173 log('ceph bootstrapped, rescanning disks')
174 emit_cephconf()
175 for dev in get_devices():
176 ceph.osdize(dev, config('osd-format'),
177- config('osd-journal'), config('osd-reformat'),
178+ osd_journal, config('osd-reformat'),
179 config('ignore-device-errors'))
180 ceph.start_osds(get_devices())
181
182@@ -186,6 +216,13 @@
183 else:
184 return []
185
186+def get_journal_devices():
187+ osd_journal = config('osd-journal')
188+ if not osd_journal:
189+ return set()
190+ osd_journal = [l.strip() for l in config('osd-journal').split(' ')]
191+ osd_journal = set(filter(os.path.exists, osd_journal))
192+ return osd_journal
193
194 @hooks.hook('mon-relation-changed',
195 'mon-relation-departed')
196@@ -195,11 +232,7 @@
197 log('mon has provided conf- scanning disks')
198 emit_cephconf()
199 ceph.import_osd_bootstrap_key(bootstrap_key)
200- for dev in get_devices():
201- ceph.osdize(dev, config('osd-format'),
202- config('osd-journal'), config('osd-reformat'),
203- config('ignore-device-errors'))
204- ceph.start_osds(get_devices())
205+ prepare_disks_and_activate()
206 else:
207 log('mon cluster has not yet provided conf')
208

Subscribers

People subscribed via source and target branches