From a52acb97602c98c87205bf8f226dee51dd8fd06b Mon Sep 17 00:00:00 2001 From: Chris MacNaughton Date: Fri, 9 Dec 2016 15:02:02 -0500 Subject: [PATCH] Add availability_zone to the OSD configuration Addition of configurable availability_zone allows the administrator to deploy Ceph with two dimensions of crush locations, one from config and one from Juju's availability zone Change-Id: Icd0ee2eeaea8bad2b78f2ed46176084e01601261 --- config.yaml | 13 ++++++++++++- hooks/ceph_hooks.py | 25 +++++++++++++++++++++++++ unit_tests/test_ceph_hooks.py | 3 ++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/config.yaml b/config.yaml index 26804cf..3b5137a 100644 --- a/config.yaml +++ b/config.yaml @@ -191,10 +191,21 @@ options: kernel.threads-max: 2097152 }' description: | YAML-formatted associative array of sysctl key/value pairs to be set - persistently. By default we set pid_max, max_map_count and + persistently. By default we set pid_max, max_map_count and threads-max to a high value to avoid problems with large numbers (>20) of OSDs recovering. very large clusters should set those values even higher (e.g. max for kernel.pid_max is 4194303). + customize-failure-domain: + type: boolean + default: false + description: | + Setting this to true will tell Ceph to replicate across Juju's + Availability Zone instead of specifically by host. + availability_zone: + type: string + default: + description: | + Custom availablility zone to provide to Ceph for the OSD placement nagios_context: type: string default: "juju" diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index 6fd1e16..f93c81d 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -16,6 +16,7 @@ import os import sys +import socket sys.path.append('lib') import ceph @@ -150,6 +151,19 @@ def install(): apt_install(packages=ceph.PACKAGES, fatal=True) +def az_info(): + az_info = "" + juju_az_info = os.environ.get('JUJU_AVAILABILITY_ZONE') + if juju_az_info: + az_info = "{} juju_availability_zone={}".format(az_info, juju_az_info) + config_az = config("availability_zone") + if config_az: + az_info = "{} config_availability_zone={}".format(az_info, config_az) + if az_info != "": + log("AZ Info: " + az_info) + return az_info + + def use_short_objects(): ''' Determine whether OSD's should be configured with @@ -199,6 +213,17 @@ def get_ceph_context(): cephcontext['public_addr'] = get_public_addr() cephcontext['cluster_addr'] = get_cluster_addr() + if config('customize-failure-domain'): + az = az_info() + if az: + cephcontext['crush_location'] = "root=default {} host={}" \ + .format(az, socket.gethostname()) + else: + log( + "Your Juju environment doesn't" + "have support for Availability Zones" + ) + # NOTE(dosaboy): these sections must correspond to what is supported in the # config template. sections = ['global', 'mds', 'osd', 'mon'] diff --git a/unit_tests/test_ceph_hooks.py b/unit_tests/test_ceph_hooks.py index d61762e..25ae4db 100644 --- a/unit_tests/test_ceph_hooks.py +++ b/unit_tests/test_ceph_hooks.py @@ -29,7 +29,8 @@ CHARM_CONFIG = {'config-flags': '', 'osd-journal-size': 1024, 'use-direct-io': True, 'osd-format': 'ext4', - 'prefer-ipv6': False} + 'prefer-ipv6': False, + 'customize-failure-domain': False} class CephHooksTestCase(unittest.TestCase):