From 354102ebd9ab32bc85517754f23ac8257480795d Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Mon, 14 Aug 2023 19:12:42 -0300 Subject: [PATCH] Fix pool names in RadosGW charm The latest Ceph versions forbid pool names that start with a dot. Since the RadosGW charm uses pools named so extensively, this patchset fixes that issue. In addition, the Ceph libraries are synced as well, since they were outdated. (cherry-picked from commit 4bc15968fe43f6f86150331f40dba4b2cadb983b) Change-Id: I9cdf891f503b749f36225ea07a7a571af1b58e9c --- actions.yaml | 2 +- charmcraft.yaml | 3 +++ hooks/ceph_rgw.py | 13 ++++++++++--- test-requirements.txt | 1 + unit_tests/test_ceph.py | 16 +--------------- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/actions.yaml b/actions.yaml index 90a0521..abe46ad 100644 --- a/actions.yaml +++ b/actions.yaml @@ -1,7 +1,7 @@ pause: description: Pause the ceph-radosgw unit. resume: - descrpition: Resume the ceph-radosgw unit. + description: Resume the ceph-radosgw unit. promote: description: Promote the zone associated with the local units to master/default (multi-site). readonly: diff --git a/charmcraft.yaml b/charmcraft.yaml index f612172..ac8ec1e 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -27,6 +27,9 @@ bases: architectures: - amd64 run-on: + - name: ubuntu + channel: "20.04" + architectures: [amd64, s390x, ppc64el, arm64] - name: ubuntu channel: "22.04" architectures: [amd64, s390x, ppc64el, arm64] diff --git a/hooks/ceph_rgw.py b/hooks/ceph_rgw.py index 463c281..d3a9860 100644 --- a/hooks/ceph_rgw.py +++ b/hooks/ceph_rgw.py @@ -79,6 +79,10 @@ def import_radosgw_key(key, name=None): return False +def normalize_pool_name(pool): + return pool[1:] if pool.startswith('.') else pool + + def get_create_rgw_pools_rq(prefix=None): """Pre-create RGW pools so that they have the correct settings. @@ -101,6 +105,8 @@ def _add_light_pool(rq, pool, pg_num, prefix=None): w = weights.get(pool, 0.10) if prefix: pool = "{prefix}{pool}".format(prefix=prefix, pool=pool) + + pool = normalize_pool_name(pool) if pg_num > 0: rq.add_op_create_pool(name=pool, replica_count=replicas, pg_num=pg_num, group='objects', @@ -162,7 +168,7 @@ def _add_light_pool(rq, pool, pg_num, prefix=None): # the function arguments. Until then we need to build the dict # prior to the function call. kwargs = { - 'name': pool, + 'name': normalize_pool_name(pool), 'erasure_profile': profile_name, 'weight': bucket_weight, 'group': "objects", @@ -178,7 +184,7 @@ def _add_light_pool(rq, pool, pg_num, prefix=None): # the function arguments. Until then we need to build the dict # prior to the function call. kwargs = { - 'name': pool, + 'name': normalize_pool_name(pool), 'replica_count': replicas, 'weight': bucket_weight, 'group': 'objects', @@ -209,7 +215,8 @@ def _add_light_pool(rq, pool, pg_num, prefix=None): for pool in light: _add_light_pool(rq, pool, pg_num, prefix) - _add_light_pool(rq, '.rgw.root', pg_num) + # RadosGW creates this pool automatically from Quincy on. + # _add_light_pool(rq, '.rgw.root', pg_num) if config('restrict-ceph-pools'): rq.add_op_request_access_to_group(name="objects", diff --git a/test-requirements.txt b/test-requirements.txt index 819ba26..a8663e5 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -28,3 +28,4 @@ git+https://opendev.org/openstack/tempest.git#egg=tempest pyopenssl<=22.0.0 croniter # needed for charm-rabbitmq-server unit tests +jsonschema<4.18.0 # jsonschema 4.18.0 depends on Rust (via rpds-py) diff --git a/unit_tests/test_ceph.py b/unit_tests/test_ceph.py index 28e7340..c9d23e4 100644 --- a/unit_tests/test_ceph.py +++ b/unit_tests/test_ceph.py @@ -107,9 +107,6 @@ def test_create_rgw_pools_rq_with_prefix( call('us-east.rgw.buckets.index', replica_count=3, pg_num=10, weight=None, group='objects', namespace=None, app_name='rgw', max_bytes=None, max_objects=None), - call('.rgw.root', replica_count=3, pg_num=10, weight=None, - group='objects', namespace=None, app_name='rgw', - max_bytes=None, max_objects=None), ]) # confirm operation with bluestore compression @@ -163,9 +160,6 @@ def test_create_rgw_pools_rq_with_prefix( call('us-east.rgw.buckets.index', replica_count=3, pg_num=10, weight=None, group='objects', namespace=None, app_name='rgw', max_bytes=None, max_objects=None), - call('.rgw.root', replica_count=3, pg_num=10, weight=None, - group='objects', namespace=None, app_name='rgw', - max_bytes=None, max_objects=None), ]) @patch.object(utils.context, 'CephBlueStoreCompressionContext') @@ -228,9 +222,6 @@ def test_create_rgw_pools_rq_no_prefix_post_jewel( call('default.rgw.buckets.index', replica_count=3, pg_num=None, weight=3.0, group='objects', namespace=None, app_name='rgw', max_bytes=None, max_objects=None), - call('.rgw.root', replica_count=3, pg_num=None, weight=0.1, - group='objects', namespace=None, app_name='rgw', - max_bytes=None, max_objects=None), ]) mock_request_access.assert_called_with(key_name='radosgw.gateway', name='objects', @@ -287,9 +278,6 @@ def test_create_rgw_pools_rq_no_prefix_post_jewel( call('default.rgw.buckets.index', replica_count=3, pg_num=None, weight=3.0, group='objects', namespace=None, app_name='rgw', max_bytes=None, max_objects=None), - call('.rgw.root', replica_count=3, pg_num=None, weight=0.1, - group='objects', namespace=None, app_name='rgw', - max_bytes=None, max_objects=None), ]) @patch.object(utils.context, 'CephBlueStoreCompressionContext') @@ -365,9 +353,7 @@ def test_create_rgw_pools_rq_no_prefix_ec(self, mock_broker, call(weight=3.00, replica_count=3, name='default.rgw.buckets.index', group='objects', app_name='rgw'), - call(weight=0.10, replica_count=3, name='.rgw.root', - group='objects', app_name='rgw')], - ) + ],) mock_request_access.assert_called_with(key_name='radosgw.gateway', name='objects', permission='rwx')