From 1991eb781527ea3073ee71dec71aef968a0118fb Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 15 Nov 2024 12:09:41 +0000 Subject: [PATCH] Sync/rebuild for Dalmatian/Epoxy updates Refresh and rebuild charm for awareness of Dalmatian and Epoxy Cloud Archive releases. Change-Id: I290ac45bfd84b95d7301c391b8ca88c4bd152bd5 --- hooks/charmhelpers/contrib/openstack/utils.py | 2 ++ hooks/charmhelpers/core/hookenv.py | 5 +++- hooks/charmhelpers/fetch/ubuntu.py | 20 +++++++++++++++ lib/charms_ceph/broker.py | 25 ++++++++----------- lib/charms_ceph/utils.py | 21 +++++++++++----- 5 files changed, 52 insertions(+), 21 deletions(-) diff --git a/hooks/charmhelpers/contrib/openstack/utils.py b/hooks/charmhelpers/contrib/openstack/utils.py index 82c28d8e..ac52d797 100644 --- a/hooks/charmhelpers/contrib/openstack/utils.py +++ b/hooks/charmhelpers/contrib/openstack/utils.py @@ -162,6 +162,8 @@ OPENSTACK_CODENAMES = OrderedDict([ ('2023.1', 'antelope'), ('2023.2', 'bobcat'), ('2024.1', 'caracal'), + ('2024.2', 'dalmatian'), + ('2025.1', 'epoxy'), ]) # The ugly duckling - must list releases oldest to newest diff --git a/hooks/charmhelpers/core/hookenv.py b/hooks/charmhelpers/core/hookenv.py index 370c3e8f..1e810a25 100644 --- a/hooks/charmhelpers/core/hookenv.py +++ b/hooks/charmhelpers/core/hookenv.py @@ -18,7 +18,10 @@ # Charm Helpers Developers import copy -from distutils.version import LooseVersion +try: + from distutils.version import LooseVersion +except ImportError: + from looseversion import LooseVersion from enum import Enum from functools import wraps from collections import namedtuple, UserDict diff --git a/hooks/charmhelpers/fetch/ubuntu.py b/hooks/charmhelpers/fetch/ubuntu.py index d0089eb7..fdcad025 100644 --- a/hooks/charmhelpers/fetch/ubuntu.py +++ b/hooks/charmhelpers/fetch/ubuntu.py @@ -254,6 +254,22 @@ CLOUD_ARCHIVE_POCKETS = { 'caracal/proposed': 'jammy-proposed/caracal', 'jammy-caracal/proposed': 'jammy-proposed/caracal', 'jammy-proposed/caracal': 'jammy-proposed/caracal', + # dalmatian + 'dalmatian': 'noble-updates/dalmatian', + 'noble-dalmatian': 'noble-updates/dalmatian', + 'noble-dalmatian/updates': 'noble-updates/dalmatian', + 'noble-updates/dalmatian': 'noble-updates/dalmatian', + 'dalmatian/proposed': 'noble-proposed/dalmatian', + 'noble-dalmatian/proposed': 'noble-proposed/dalmatian', + 'noble-proposed/dalmatian': 'noble-proposed/dalmatian', + # epoxy + 'epoxy': 'noble-updates/epoxy', + 'noble-epoxy': 'noble-updates/epoxy', + 'noble-epoxy/updates': 'noble-updates/epoxy', + 'noble-updates/epoxy': 'noble-updates/epoxy', + 'epoxy/proposed': 'noble-proposed/epoxy', + 'noble-epoxy/proposed': 'noble-proposed/epoxy', + 'noble-proposed/epoxy': 'noble-proposed/epoxy', # OVN 'focal-ovn-22.03': 'focal-updates/ovn-22.03', @@ -288,6 +304,8 @@ OPENSTACK_RELEASES = ( 'antelope', 'bobcat', 'caracal', + 'dalmatian', + 'epoxy', ) @@ -318,6 +336,8 @@ UBUNTU_OPENSTACK_RELEASE = OrderedDict([ ('lunar', 'antelope'), ('mantic', 'bobcat'), ('noble', 'caracal'), + ('oracular', 'dalmatian'), + ('plucky', 'epoxy'), ]) diff --git a/lib/charms_ceph/broker.py b/lib/charms_ceph/broker.py index 7f453ec8..7ca96922 100644 --- a/lib/charms_ceph/broker.py +++ b/lib/charms_ceph/broker.py @@ -769,7 +769,7 @@ def handle_create_cephfs(request, service): log(msg, level=ERROR) return {'exit-code': 1, 'stderr': msg} - if get_cephfs(service=service): + if cephfs_name in get_cephfs(service=service): # CephFS new has already been called log("CephFS already created") return @@ -853,15 +853,10 @@ def handle_create_cephfs_client(request, service): log(msg, level=ERROR) return {'exit-code': 1, 'stderr': msg} - # Check that the provided fs_name exists - if fs_name not in get_cephfs(service=service): - msg = ("Ceph filesystem {} does not exist." - + "Cannot authorize client").format( - fs_name) - log(msg, level=ERROR) - return {'exit-code': 1, 'stderr': msg} - - # Check that the provided client does NOT exist. + # Skip creation if the request has already been called + # This makes it a bit more compatible with older Ceph versions + # that throw when trying to authorize a user with the same + # capabilites that it currently has. try: cmd = ["ceph", "--id", service, "auth", "ls", "-f", "json"] auth_ls = json.loads(check_output(cmd, encoding="utf-8")) @@ -873,12 +868,14 @@ def handle_create_cephfs_client(request, service): return {'exit-code': 1, 'stderr': str(err)} client = "client.{}".format(client_id) - if client in (elem["entity"] for elem in auth_ls["auth_dump"]): - msg = "Client {} already exists".format(client) - log(msg, level=ERROR) - return {'exit-code': 1, 'stderr': msg} + for elem in auth_ls["auth_dump"]: + if client == elem["entity"]: + log("Client {} has already been created".format(client)) + return {'exit-code': 0, 'key': elem["key"]} # Try to authorize the client + # `ceph fs authorize` already returns the correct error + # message if the filesystem doesn't exist. try: cmd = [ "ceph", diff --git a/lib/charms_ceph/utils.py b/lib/charms_ceph/utils.py index 57cb1d7b..85e6249b 100644 --- a/lib/charms_ceph/utils.py +++ b/lib/charms_ceph/utils.py @@ -1541,11 +1541,11 @@ def get_devices(name): def osdize(dev, osd_format, osd_journal, ignore_errors=False, encrypt=False, - key_manager=CEPH_KEY_MANAGER, osd_id=None): + key_manager=CEPH_KEY_MANAGER, osd_id=None, bluestore_skip=None): if dev.startswith('/dev'): osdize_dev(dev, osd_format, osd_journal, ignore_errors, encrypt, - key_manager, osd_id) + key_manager, osd_id, bluestore_skip) else: if cmp_pkgrevno('ceph', '14.0.0') >= 0: log("Directory backed OSDs can not be created on Nautilus", @@ -1556,7 +1556,7 @@ def osdize(dev, osd_format, osd_journal, ignore_errors=False, encrypt=False, def osdize_dev(dev, osd_format, osd_journal, ignore_errors=False, encrypt=False, key_manager=CEPH_KEY_MANAGER, - osd_id=None): + osd_id=None, bluestore_skip=None): """ Prepare a block device for use as a Ceph OSD @@ -1570,6 +1570,8 @@ def osdize_dev(dev, osd_format, osd_journal, ignore_errors=False, processing :param: encrypt: Encrypt block devices using 'key_manager' :param: key_manager: Key management approach for encryption keys + :param: osd_id: The ID for the newly created OSD + :param: bluestore_skip: Bluestore parameters to skip ('wal' and/or 'db') :raises subprocess.CalledProcessError: in the event that any supporting subprocess operation failed :raises ValueError: if an invalid key_manager is provided @@ -1620,7 +1622,8 @@ def osdize_dev(dev, osd_format, osd_journal, ignore_errors=False, osd_journal, encrypt, key_manager, - osd_id) + osd_id, + bluestore_skip) else: cmd = _ceph_disk(dev, osd_format, @@ -1694,7 +1697,7 @@ def _ceph_disk(dev, osd_format, osd_journal, encrypt=False): def _ceph_volume(dev, osd_journal, encrypt=False, key_manager=CEPH_KEY_MANAGER, - osd_id=None): + osd_id=None, bluestore_skip=None): """ Prepare and activate a device for usage as a Ceph OSD using ceph-volume. @@ -1706,6 +1709,7 @@ def _ceph_volume(dev, osd_journal, encrypt=False, key_manager=CEPH_KEY_MANAGER, :param: encrypt: Use block device encryption :param: key_manager: dm-crypt Key Manager to use :param: osd_id: The OSD-id to recycle, or None to create a new one + :param: bluestore_skip: Bluestore parameters to skip ('wal' and/or 'db') :raises subprocess.CalledProcessError: in the event that any supporting LVM operation failed. :returns: list. 'ceph-volume' command and required parameters for @@ -1732,7 +1736,11 @@ def _ceph_volume(dev, osd_journal, encrypt=False, key_manager=CEPH_KEY_MANAGER, encrypt=encrypt, key_manager=key_manager)) - for extra_volume in ('wal', 'db'): + extras = ('wal', 'db') + if bluestore_skip: + extras = tuple(set(extras) - set(bluestore_skip)) + + for extra_volume in extras: devices = get_devices('bluestore-{}'.format(extra_volume)) if devices: cmd.append('--block.{}'.format(extra_volume)) @@ -2075,6 +2083,7 @@ def get_cephfs(service): for part in parts: if "name" in part: filesystems.append(part.split(' ')[1]) + return filesystems except subprocess.CalledProcessError: return []