From 72a7184dc5b14bd6c1eb6690406ae24a76c809d0 Mon Sep 17 00:00:00 2001 From: Jarred Wilson Date: Thu, 14 Jan 2021 14:07:07 -0500 Subject: [PATCH] Enable object versioning for a container This patch adds the config option rgw-swift-versioning-enabled boolean that enables swift versioning for the ceph-backed storage solution. This uses X-Versions-Location as it is the only header that radosgw interprets. closes-bug: #1910679 Change-Id: I5b42c34882b46e96f4cc92d91ec441a4bdfd76f6 --- config.yaml | 9 +++++++++ hooks/ceph_radosgw_context.py | 1 + templates/ceph.conf | 1 + unit_tests/test_ceph_radosgw_context.py | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/config.yaml b/config.yaml index f5ae44a9..d64d20f0 100644 --- a/config.yaml +++ b/config.yaml @@ -500,3 +500,12 @@ options: description: | Value of bluestore compression max blob size for solid state media on pools requested by this charm. + rgw-swift-versioning-enabled: + type: boolean + default: False + description: | + If True, swift object versioning will be enabled for radosgw. + + NOTE: X-Versions-Location is the only versioning-related header that + radosgw interprets. X-History-Location, supported by native OpenStack + Swift, is currently not supported by radosgw. diff --git a/hooks/ceph_radosgw_context.py b/hooks/ceph_radosgw_context.py index 8115e4e1..a43fd603 100644 --- a/hooks/ceph_radosgw_context.py +++ b/hooks/ceph_radosgw_context.py @@ -207,6 +207,7 @@ class MonContext(context.CephContext): # not available externally). ~tribaal 'unit_public_ip': unit_public_ip(), 'fsid': fsid, + 'rgw_swift_versioning': config('rgw-swift-versioning-enabled'), } # NOTE(dosaboy): these sections must correspond to what is supported in diff --git a/templates/ceph.conf b/templates/ceph.conf index 924927f4..ce3e7d5b 100644 --- a/templates/ceph.conf +++ b/templates/ceph.conf @@ -14,6 +14,7 @@ debug rgw = {{ loglevel }}/5 {% if ipv6 -%} ms bind ipv6 = true {% endif %} +rgw swift versioning enabled = {{ rgw_swift_versioning }} {% if global -%} # The following are user-provided options provided via the config-flags charm option. # User-provided [global] section config diff --git a/unit_tests/test_ceph_radosgw_context.py b/unit_tests/test_ceph_radosgw_context.py index cb0c039b..faf73bd1 100644 --- a/unit_tests/test_ceph_radosgw_context.py +++ b/unit_tests/test_ceph_radosgw_context.py @@ -387,6 +387,7 @@ class MonContextTest(CharmTestCase): 'ipv6': False, 'rgw_zone': 'default', 'fsid': 'testfsid', + 'rgw_swift_versioning': False, } self.assertEqual(expect, mon_ctxt()) self.assertFalse(mock_ensure_rsv_v6.called) @@ -435,6 +436,7 @@ class MonContextTest(CharmTestCase): 'ipv6': False, 'rgw_zone': 'default', 'fsid': 'testfsid', + 'rgw_swift_versioning': False, } self.assertEqual(expect, mon_ctxt()) self.assertFalse(mock_ensure_rsv_v6.called) @@ -492,6 +494,7 @@ class MonContextTest(CharmTestCase): 'ipv6': False, 'rgw_zone': 'default', 'fsid': 'testfsid', + 'rgw_swift_versioning': False, } self.assertEqual(expect, mon_ctxt()) @@ -531,6 +534,7 @@ class MonContextTest(CharmTestCase): 'ipv6': False, 'rgw_zone': 'default', 'fsid': 'testfsid', + 'rgw_swift_versioning': False, } self.assertEqual(expect, mon_ctxt())