Merge lp:~xfactor973/charms/trusty/ceph-osd/coordinated-upgrade into lp:~openstack-charmers-archive/charms/trusty/ceph-osd/next

Proposed by Chris Holcombe
Status: Needs review
Proposed branch: lp:~xfactor973/charms/trusty/ceph-osd/coordinated-upgrade
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceph-osd/next
Diff against target: 600 lines (+387/-18)
5 files modified
.bzrignore (+1/-0)
hooks/ceph.py (+155/-9)
hooks/ceph_hooks.py (+199/-5)
hooks/utils.py (+31/-3)
templates/ceph.conf (+1/-1)
To merge this branch: bzr merge lp:~xfactor973/charms/trusty/ceph-osd/coordinated-upgrade
Reviewer Review Type Date Requested Status
James Page Needs Fixing
Chris MacNaughton Pending
Review via email: mp+287376@code.launchpad.net

Description of the change

This patch allows the ceph osd cluster to upgrade themselves one by one. It does this by using the ceph monitor cluster as a locking mechanism. There are most likely edge cases with this method that I haven't thought of. Consider this code to be lightly tested. It worked fine on ec2.

To post a comment you must log in.
Revision history for this message
Chris Holcombe (xfactor973) wrote :

Note: I put the helpers up for review on charmhelpers: https://code.launchpad.net/~xfactor973/charm-helpers/ceph-keystore/+merge/287205

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

charm_lint_check #1557 ceph-osd-next for xfactor973 mp287376
    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/15210766/
Build: http://10.245.162.36:8080/job/charm_lint_check/1557/

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

charm_unit_test #1305 ceph-osd-next for xfactor973 mp287376
    UNIT OK: passed

Build: http://10.245.162.36:8080/job/charm_unit_test/1305/

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

charm_amulet_test #554 ceph-osd-next for xfactor973 mp287376
    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/15210862/
Build: http://10.245.162.36:8080/job/charm_amulet_test/554/

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

charm_unit_test #1308 ceph-osd-next for xfactor973 mp287376
    UNIT OK: passed

Build: http://10.245.162.36:8080/job/charm_unit_test/1308/

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

charm_lint_check #1562 ceph-osd-next for xfactor973 mp287376
    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/15210966/
Build: http://10.245.162.36:8080/job/charm_lint_check/1562/

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

charm_amulet_test #558 ceph-osd-next for xfactor973 mp287376
    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/15211124/
Build: http://10.245.162.36:8080/job/charm_amulet_test/558/

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

I think most of my comments on the ceph-mon proposal also apply here.

review: Needs Fixing
70. By Chris Holcombe

Add back in monitor pieces. Will separate out into another MP

Unmerged revisions

70. By Chris Holcombe

Add back in monitor pieces. Will separate out into another MP

69. By Chris Holcombe

Hash the hostname instead of the ip address. That is more portable. Works now on lxc and also on ec2

68. By Chris Holcombe

Merge upstream

67. By Chris Holcombe

It rolls!. This now upgrades and rolls the ceph osd cluster one by one

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2015-10-30 02:23:36 +0000
+++ .bzrignore 2016-03-01 16:57:01 +0000
@@ -3,3 +3,4 @@
3.tox3.tox
4.testrepository4.testrepository
5bin5bin
6.idea
67
=== modified file 'hooks/ceph.py'
--- hooks/ceph.py 2016-01-29 07:31:13 +0000
+++ hooks/ceph.py 2016-03-01 16:57:01 +0000
@@ -1,4 +1,3 @@
1
2#1#
3# Copyright 2012 Canonical Ltd.2# Copyright 2012 Canonical Ltd.
4#3#
@@ -6,20 +5,19 @@
6# James Page <james.page@canonical.com>5# James Page <james.page@canonical.com>
7# Paul Collins <paul.collins@canonical.com>6# Paul Collins <paul.collins@canonical.com>
8#7#
9
10import json8import json
11import subprocess9import subprocess
12import time10import time
13import os11import os
14import re12import re
15import sys13import sys
14import errno
16from charmhelpers.core.host import (15from charmhelpers.core.host import (
17 mkdir,16 mkdir,
18 chownr,17 chownr,
19 service_restart,
20 cmp_pkgrevno,18 cmp_pkgrevno,
21 lsb_release19 lsb_release,
22)20 service_restart)
23from charmhelpers.core.hookenv import (21from charmhelpers.core.hookenv import (
24 log,22 log,
25 ERROR,23 ERROR,
@@ -54,6 +52,137 @@
54 return "root"52 return "root"
5553
5654
55class CrushLocation(object):
56 def __init__(self, name, identifier, host, rack, row, datacenter, chassis, root):
57 self.name = name
58 self.identifier = identifier
59 self.host = host
60 self.rack = rack
61 self.row = row
62 self.datacenter = datacenter
63 self.chassis = chassis
64 self.root = root
65
66
67"""
68{"nodes":[{"id":-1,"name":"default","type":"root","type_id":10,"children":[-4,-3,-2]},{"id":-2,"name":"ip-172-31-10-122","type":"host","type_id":1,"children":[0]},{"id":0,"name":"osd.0","exists":1,"type":"osd","type_id":0,"status":"up","reweight":"1.000000","crush_weight":"1.000000","depth":2},{"id":-3,"name":"ip-172-31-25-187","type":"host","type_id":1,"children":[1]},{"id":1,"name":"osd.1","exists":1,"type":"osd","type_id":0,"status":"up","reweight":"1.000000","crush_weight":"1.000000","depth":2},{"id":-4,"name":"ip-172-31-38-24","type":"host","type_id":1,"children":[2]},{"id":2,"name":"osd.2","exists":1,"type":"osd","type_id":0,"status":"up","reweight":"1.000000","crush_weight":"1.000000","depth":2}],"stray":[]}
69"""
70
71
72def get_osd_tree():
73 """
74 Returns the current osd map in JSON.
75 :return: JSON String. :raise: ValueError if the monmap fails to parse.
76 Also raises CalledProcessError if our ceph command fails
77 """
78 try:
79 tree = subprocess.check_output(
80 ['sudo', '-u', ceph_user(),
81 'ceph', 'osd', 'tree', '--format=json'])
82 try:
83 json_tree = json.loads(tree)
84 crush_list = []
85 # Make sure children are present in the json
86 if not json_tree['nodes']:
87 return None
88 child_ids = json_tree['nodes'][0]['children']
89 for child in json_tree['nodes']:
90 if child['id'] in child_ids:
91 crush_list.append(
92 CrushLocation(
93 name=child.get('name'),
94 identifier=child['id'],
95 host=child.get('host'),
96 rack=child.get('rack'),
97 row=child.get('row'),
98 datacenter=child.get('datacenter'),
99 chassis=child.get('chassis'),
100 root=child.get('root')
101 )
102 )
103 return crush_list
104 except ValueError as v:
105 log("Unable to parse ceph tree json: {}. Error: {}".format(
106 tree, v.message))
107 raise
108 except subprocess.CalledProcessError as e:
109 log("ceph osd tree command failed with message: {}".format(
110 e.message))
111 raise
112
113
114def monitor_key_delete(key):
115 """
116 Deletes a key value pair on the monitor cluster.
117 :param key: String. The key to delete.
118 """
119 try:
120 subprocess.check_output(
121 ['sudo', '-u', ceph_user(),
122 'ceph', 'config-key', 'del', str(key)])
123 except subprocess.CalledProcessError as e:
124 log("Monitor config-key put failed with message: {}".format(
125 e.message))
126 raise
127
128
129def monitor_key_set(key, value):
130 """
131 Sets a key value pair on the monitor cluster.
132 :param key: String. The key to set.
133 :param value: The value to set. This will be converted to a string
134 before setting
135 """
136 try:
137 subprocess.check_output(
138 ['sudo', '-u', ceph_user(),
139 'ceph', 'config-key', 'put', str(key), str(value)])
140 except subprocess.CalledProcessError as e:
141 log("Monitor config-key put failed with message: {}".format(
142 e.message))
143 raise
144
145
146def monitor_key_get(key):
147 """
148 Gets the value of an existing key in the monitor cluster.
149 :param key: String. The key to search for.
150 :return: Returns the value of that key or None if not found.
151 """
152 try:
153 output = subprocess.check_output(
154 ['sudo', '-u', ceph_user(),
155 'ceph', 'config-key', 'get', str(key)])
156 return output
157 except subprocess.CalledProcessError as e:
158 log("Monitor config-key get failed with message: {}".format(
159 e.message))
160 return None
161
162
163def monitor_key_exists(key):
164 """
165 Searches for the existence of a key in the monitor cluster.
166 :param key: String. The key to search for
167 :return: Returns True if the key exists, False if not and raises an
168 exception if an unknown error occurs.
169 """
170 try:
171 subprocess.check_call(
172 ['sudo', '-u', ceph_user(),
173 'ceph', 'config-key', 'exists', str(key)])
174 # I can return true here regardless because Ceph returns
175 # ENOENT if the key wasn't found
176 return True
177 except subprocess.CalledProcessError as e:
178 if e.returncode == errno.ENOENT:
179 return False
180 else:
181 log("Unknown error from ceph config-get exists: {} {}".format(
182 e.returncode, e.message))
183 raise
184
185
57def get_version():186def get_version():
58 '''Derive Ceph release from an installed package.'''187 '''Derive Ceph release from an installed package.'''
59 import apt_pkg as apt188 import apt_pkg as apt
@@ -64,7 +193,7 @@
64 pkg = cache[package]193 pkg = cache[package]
65 except:194 except:
66 # the package is unknown to the current apt cache.195 # the package is unknown to the current apt cache.
67 e = 'Could not determine version of package with no installation '\196 e = 'Could not determine version of package with no installation ' \
68 'candidate: %s' % package197 'candidate: %s' % package
69 error_out(e)198 error_out(e)
70199
@@ -165,6 +294,7 @@
165 # Ignore any errors for this call294 # Ignore any errors for this call
166 subprocess.call(cmd)295 subprocess.call(cmd)
167296
297
168DISK_FORMATS = [298DISK_FORMATS = [
169 'xfs',299 'xfs',
170 'ext4',300 'ext4',
@@ -211,6 +341,7 @@
211341
212342
213_bootstrap_keyring = "/var/lib/ceph/bootstrap-osd/ceph.keyring"343_bootstrap_keyring = "/var/lib/ceph/bootstrap-osd/ceph.keyring"
344_upgrade_keyring = "/etc/ceph/ceph.client.admin.keyring"
214345
215346
216def is_bootstrapped():347def is_bootstrapped():
@@ -236,6 +367,21 @@
236 ]367 ]
237 subprocess.check_call(cmd)368 subprocess.check_call(cmd)
238369
370
371def import_osd_upgrade_key(key):
372 if not os.path.exists(_upgrade_keyring):
373 cmd = [
374 "sudo",
375 "-u",
376 ceph_user(),
377 'ceph-authtool',
378 _upgrade_keyring,
379 '--create-keyring',
380 '--name=client.admin',
381 '--add-key={}'.format(key)
382 ]
383 subprocess.check_call(cmd)
384
239# OSD caps taken from ceph-create-keys385# OSD caps taken from ceph-create-keys
240_osd_bootstrap_caps = {386_osd_bootstrap_caps = {
241 'mon': [387 'mon': [
@@ -402,7 +548,7 @@
402548
403549
404def maybe_zap_journal(journal_dev):550def maybe_zap_journal(journal_dev):
405 if (is_osd_disk(journal_dev)):551 if is_osd_disk(journal_dev):
406 log('Looks like {} is already an OSD data'552 log('Looks like {} is already an OSD data'
407 ' or journal, skipping.'.format(journal_dev))553 ' or journal, skipping.'.format(journal_dev))
408 return554 return
@@ -445,7 +591,7 @@
445 log('Path {} is not a block device - bailing'.format(dev))591 log('Path {} is not a block device - bailing'.format(dev))
446 return592 return
447593
448 if (is_osd_disk(dev) and not reformat_osd):594 if is_osd_disk(dev) and not reformat_osd:
449 log('Looks like {} is already an'595 log('Looks like {} is already an'
450 ' OSD data or journal, skipping.'.format(dev))596 ' OSD data or journal, skipping.'.format(dev))
451 return597 return
@@ -512,7 +658,7 @@
512658
513659
514def get_running_osds():660def get_running_osds():
515 '''Returns a list of the pids of the current running OSD daemons'''661 """Returns a list of the pids of the current running OSD daemons"""
516 cmd = ['pgrep', 'ceph-osd']662 cmd = ['pgrep', 'ceph-osd']
517 try:663 try:
518 result = subprocess.check_output(cmd)664 result = subprocess.check_output(cmd)
519665
=== modified file 'hooks/ceph_hooks.py'
--- hooks/ceph_hooks.py 2016-02-25 15:48:22 +0000
+++ hooks/ceph_hooks.py 2016-03-01 16:57:01 +0000
@@ -8,12 +8,17 @@
8#8#
99
10import glob10import glob
11import hashlib
11import os12import os
13import random
12import shutil14import shutil
15import subprocess
13import sys16import sys
14import tempfile17import tempfile
18import time
1519
16import ceph20import ceph
21from charmhelpers.core import hookenv
17from charmhelpers.core.hookenv import (22from charmhelpers.core.hookenv import (
18 log,23 log,
19 ERROR,24 ERROR,
@@ -39,13 +44,13 @@
39 filter_installed_packages,44 filter_installed_packages,
40)45)
41from charmhelpers.core.sysctl import create as create_sysctl46from charmhelpers.core.sysctl import create as create_sysctl
47from charmhelpers.core import host
4248
43from utils import (49from utils import (
44 get_host_ip,50 get_host_ip,
45 get_networks,51 get_networks,
46 assert_charm_supports_ipv6,52 assert_charm_supports_ipv6,
47 render_template,53 render_template)
48)
4954
50from charmhelpers.contrib.openstack.alternatives import install_alternative55from charmhelpers.contrib.openstack.alternatives import install_alternative
51from charmhelpers.contrib.network.ip import (56from charmhelpers.contrib.network.ip import (
@@ -57,6 +62,188 @@
5762
58hooks = Hooks()63hooks = Hooks()
5964
65# A dict of valid ceph upgrade paths. Mapping is old -> new
66upgrade_paths = {
67 'cloud:trusty-juno': 'cloud:trusty-kilo',
68 'cloud:trusty-kilo': 'cloud:trusty-liberty',
69 'cloud:trusty-liberty': None,
70}
71
72
73def pretty_print_upgrade_paths():
74 lines = []
75 for key, value in upgrade_paths.iteritems():
76 lines.append("{} -> {}".format(key, value))
77 return lines
78
79
80def check_for_upgrade():
81 c = hookenv.config()
82 old_version = c.previous('source')
83 log('old_version: {}'.format(old_version))
84 # Strip all whitespace
85 new_version = config('source')
86 if new_version:
87 # replace all whitespace
88 new_version = new_version.replace(' ', '')
89 log('new_version: {}'.format(new_version))
90
91 if old_version in upgrade_paths:
92 if new_version == upgrade_paths[old_version]:
93 log("{} to {} is a valid upgrade path. Proceeding.".format(
94 old_version, new_version))
95 roll_osd_cluster(new_version)
96 else:
97 # Log a helpful error message
98 log("Invalid upgrade path from {} to {}. "
99 "Valid paths are: {}".format(old_version,
100 new_version,
101 pretty_print_upgrade_paths()))
102
103
104def lock_and_roll(my_hash):
105 start_timestamp = time.time()
106
107 ceph.monitor_key_set("{}_start".format(my_hash), start_timestamp)
108 log("Rolling")
109 # This should be quick
110 upgrade_osd()
111 log("Done")
112
113 stop_timestamp = time.time()
114 # Set a key to inform others I am finished
115 ceph.monitor_key_set("{}_done".format(my_hash), stop_timestamp)
116
117
118def get_hostname():
119 try:
120 with open('/etc/hostname', 'r') as host_file:
121 host_lines = host_file.readlines()
122 if host_lines:
123 return host_lines[0].strip()
124 except IOError:
125 raise
126
127
128# TODO: Timeout busted nodes and keep moving forward
129# Edge cases:
130# 1. Previous node dies on upgrade, can we retry?
131# 2. This assumes that the osd failure domain is not set to osd.
132# It rolls an entire server at a time.
133def roll_osd_cluster(new_version):
134 """
135 This is tricky to get right so here's what we're going to do.
136 There's 2 possible cases: Either I'm first in line or not.
137 If I'm not first in line I'll wait a random time between 5-30 seconds
138 and test to see if the previous osd is upgraded yet.
139
140 TODO: If you're not in the same failure domain it's safe to upgrade
141 1. Examine all pools and adopt the most strict failure domain policy
142 Example: Pool 1: Failure domain = rack
143 Pool 2: Failure domain = host
144 Pool 3: Failure domain = row
145
146 outcome: Failure domain = host
147 """
148 log('roll_osd_cluster called with {}'.format(new_version))
149 my_hostname = None
150 try:
151 my_hostname = get_hostname()
152 except IOError as err:
153 log("Failed to read /etc/hostname. Error: {}".format(err.message))
154 status_set('blocked', 'failed to upgrade monitor')
155
156 my_hash = hashlib.sha224(my_hostname).hexdigest()
157 # A sorted list of hashed osd names
158 osd_hashed_dict = {}
159 osd_tree_list = ceph.get_osd_tree()
160 osd_hashed_list = sorted([hashlib.sha224(
161 i.name.encode('utf-8')).hexdigest() for i in osd_tree_list])
162 # Save a hash : name mapping so we can show the user which
163 # unit name we're waiting on
164 for i in osd_tree_list:
165 osd_hashed_dict[
166 hashlib.sha224(
167 i.name.encode('utf-8')).hexdigest()
168 ] = i.name
169 log("osd_hashed_list: {}".format(osd_hashed_list))
170 try:
171 position = osd_hashed_list.index(my_hash)
172 log("upgrade position: {}".format(position))
173 if position == 0:
174 # I'm first! Roll
175 # First set a key to inform others I'm about to roll
176 lock_and_roll(my_hash=my_hash)
177 else:
178 # Check if the previous node has finished
179 status_set('blocked',
180 'Waiting on {} to finish upgrading'.format(
181 osd_hashed_dict[
182 osd_hashed_list[position - 1]]
183 ))
184 previous_node_finished = ceph.monitor_key_exists(
185 "{}_done".format(osd_hashed_list[position - 1]))
186
187 # Block and wait on the previous nodes to finish
188 while previous_node_finished is False:
189 log("previous is not finished. Waiting")
190 # Has this node been trying to upgrade for longer than 10 minutes?
191 # If so then move on and consider that node dead.
192
193 # NOTE: This assumes the clusters clocks are somewhat accurate
194 current_timestamp = time.time()
195 previous_node_start_time = ceph.monitor_key_get(
196 "{}_start".format(osd_hashed_list[position - 1]))
197 if (current_timestamp - (10 * 60)) > previous_node_start_time:
198 # Previous node is probably dead. Lets move on
199 if previous_node_start_time is not None:
200 log("Previous node {} appears dead. {} > {} Moving on".format(
201 osd_hashed_dict[osd_hashed_list[position - 1]],
202 (current_timestamp - (10 * 60)),
203 previous_node_start_time
204 ))
205 lock_and_roll(my_hash=my_hash)
206 else:
207 # ??
208 pass
209 else:
210 # I have to wait. Sleep a random amount of time and then
211 # check if I can lock,upgrade and roll.
212 time.sleep(random.randrange(5, 30))
213 previous_node_finished = ceph.monitor_key_exists(
214 "{}_done".format(osd_hashed_list[position - 1]))
215 lock_and_roll(my_hash=my_hash)
216 except ValueError:
217 log("Unable to find ceph monitor hash in list")
218 status_set('blocked', 'failed to upgrade monitor')
219
220
221def upgrade_osd():
222 add_source(config('source'), config('key'))
223
224 current_version = ceph.get_version()
225 status_set("maintenance", "Upgrading osd")
226 log("Current ceph version is {}".format(current_version))
227 new_version = config('release-version')
228 log("Upgrading to: {}".format(new_version))
229
230 try:
231 add_source(config('source'), config('key'))
232 apt_update(fatal=True)
233 except subprocess.CalledProcessError as err:
234 log("Adding the ceph source failed with message: {}".format(
235 err.message))
236 status_set("blocked", "Upgrade to {} failed".format(new_version))
237 try:
238 host.service_stop('ceph-osd-all')
239 apt_install(packages=ceph.PACKAGES, fatal=True)
240 host.service_start('ceph-osd-all')
241 status_set("active", "")
242 except subprocess.CalledProcessError as err:
243 log("Stopping ceph and upgrading packages failed "
244 "with message: {}".format(err.message))
245 status_set("blocked", "Upgrade to {} failed".format(new_version))
246
60247
61def install_upstart_scripts():248def install_upstart_scripts():
62 # Only install upstart configurations for older versions249 # Only install upstart configurations for older versions
@@ -113,6 +300,7 @@
113 install_alternative('ceph.conf', '/etc/ceph/ceph.conf',300 install_alternative('ceph.conf', '/etc/ceph/ceph.conf',
114 charm_ceph_conf, 90)301 charm_ceph_conf, 90)
115302
303
116JOURNAL_ZAPPED = '/var/lib/ceph/journal_zapped'304JOURNAL_ZAPPED = '/var/lib/ceph/journal_zapped'
117305
118306
@@ -147,6 +335,9 @@
147335
148@hooks.hook('config-changed')336@hooks.hook('config-changed')
149def config_changed():337def config_changed():
338 # Check if an upgrade was requested
339 check_for_upgrade()
340
150 # Pre-flight checks341 # Pre-flight checks
151 if config('osd-format') not in ceph.DISK_FORMATS:342 if config('osd-format') not in ceph.DISK_FORMATS:
152 log('Invalid OSD disk format configuration specified', level=ERROR)343 log('Invalid OSD disk format configuration specified', level=ERROR)
@@ -160,7 +351,7 @@
160 create_sysctl(sysctl_dict, '/etc/sysctl.d/50-ceph-osd-charm.conf')351 create_sysctl(sysctl_dict, '/etc/sysctl.d/50-ceph-osd-charm.conf')
161352
162 e_mountpoint = config('ephemeral-unmount')353 e_mountpoint = config('ephemeral-unmount')
163 if (e_mountpoint and ceph.filesystem_mounted(e_mountpoint)):354 if e_mountpoint and ceph.filesystem_mounted(e_mountpoint):
164 umount(e_mountpoint)355 umount(e_mountpoint)
165 prepare_disks_and_activate()356 prepare_disks_and_activate()
166357
@@ -189,8 +380,9 @@
189 hosts = []380 hosts = []
190 for relid in relation_ids('mon'):381 for relid in relation_ids('mon'):
191 for unit in related_units(relid):382 for unit in related_units(relid):
192 addr = relation_get('ceph-public-address', unit, relid) or \383 addr = relation_get(
193 get_host_ip(relation_get('private-address', unit, relid))384 'ceph-public-address', unit, relid) or \
385 get_host_ip(relation_get('private-address', unit, relid))
194386
195 if addr:387 if addr:
196 hosts.append('{}:6789'.format(format_ipv6_addr(addr) or addr))388 hosts.append('{}:6789'.format(format_ipv6_addr(addr) or addr))
@@ -246,10 +438,12 @@
246 'mon-relation-departed')438 'mon-relation-departed')
247def mon_relation():439def mon_relation():
248 bootstrap_key = relation_get('osd_bootstrap_key')440 bootstrap_key = relation_get('osd_bootstrap_key')
441 upgrade_key = relation_get('osd_upgrade_key')
249 if get_fsid() and get_auth() and bootstrap_key:442 if get_fsid() and get_auth() and bootstrap_key:
250 log('mon has provided conf- scanning disks')443 log('mon has provided conf- scanning disks')
251 emit_cephconf()444 emit_cephconf()
252 ceph.import_osd_bootstrap_key(bootstrap_key)445 ceph.import_osd_bootstrap_key(bootstrap_key)
446 ceph.import_osd_upgrade_key(upgrade_key)
253 prepare_disks_and_activate()447 prepare_disks_and_activate()
254 else:448 else:
255 log('mon cluster has not yet provided conf')449 log('mon cluster has not yet provided conf')
256450
=== modified file 'hooks/utils.py'
--- hooks/utils.py 2016-02-18 17:10:53 +0000
+++ hooks/utils.py 2016-03-01 16:57:01 +0000
@@ -1,4 +1,3 @@
1
2#1#
3# Copyright 2012 Canonical Ltd.2# Copyright 2012 Canonical Ltd.
4#3#
@@ -12,8 +11,8 @@
12from charmhelpers.core.hookenv import (11from charmhelpers.core.hookenv import (
13 unit_get,12 unit_get,
14 cached,13 cached,
15 config14 config,
16)15 status_set)
17from charmhelpers.fetch import (16from charmhelpers.fetch import (
18 apt_install,17 apt_install,
19 filter_installed_packages18 filter_installed_packages
@@ -87,6 +86,35 @@
87 return answers[0].address86 return answers[0].address
8887
8988
89def get_public_addr():
90 return get_network_addrs('ceph-public-network')[0]
91
92
93def get_network_addrs(config_opt):
94 """Get all configured public networks addresses.
95
96 If public network(s) are provided, go through them and return the
97 addresses we have configured on any of those networks.
98 """
99 addrs = []
100 networks = config(config_opt)
101 if networks:
102 networks = networks.split()
103 addrs = [get_address_in_network(n) for n in networks]
104 addrs = [a for a in addrs if a]
105
106 if not addrs:
107 if networks:
108 msg = ("Could not find an address on any of '%s' - resolve this "
109 "error to retry" % networks)
110 status_set('blocked', msg)
111 raise Exception(msg)
112 else:
113 return [get_host_ip()]
114
115 return addrs
116
117
90def get_networks(config_opt='ceph-public-network'):118def get_networks(config_opt='ceph-public-network'):
91 """Get all configured networks from provided config option.119 """Get all configured networks from provided config option.
92120
93121
=== modified file 'templates/ceph.conf'
--- templates/ceph.conf 2016-01-18 16:42:36 +0000
+++ templates/ceph.conf 2016-03-01 16:57:01 +0000
@@ -6,7 +6,7 @@
6auth service required = {{ auth_supported }}6auth service required = {{ auth_supported }}
7auth client required = {{ auth_supported }}7auth client required = {{ auth_supported }}
8{% endif %}8{% endif %}
9keyring = /etc/ceph/$cluster.$name.keyring9keyring = /etc/ceph/ceph.client.admin.keyring
10mon host = {{ mon_hosts }}10mon host = {{ mon_hosts }}
11fsid = {{ fsid }}11fsid = {{ fsid }}
1212

Subscribers

People subscribed via source and target branches