]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_admin.cc: Handle pg_ver and source_zone explicitly 52007/head
authorTom Coldrick <tcoldrick@bloomberg.com>
Tue, 6 Jun 2023 13:54:43 +0000 (09:54 -0400)
committerTom Coldrick <tcoldrick@bloomberg.com>
Tue, 25 Jul 2023 09:32:24 +0000 (10:32 +0100)
At present, the pg_ver and source_zone attrs are handled as if they're
strings, but are in fact unsigned integer types.  This means that when
dumped they yield invalid UTF-8 characters.  As well as hiding the
meaning of these attributes, this also means that we're not compliant
with RFC 8259 for JSON, which specifies that externally visible JSON
must be UTF-8 encoded [0].

[0]: https://rfc-editor.org/rfc/rfc8259#section-8.1

Signed-off-by: Tom Coldrick <tcoldrick@bloomberg.com>
qa/workunits/rgw/test_rgw_d4n.py
src/rgw/rgw_admin.cc

index c5ba5ec6568812052e934b74492a2bc90ea7abb5..85d0dc23907eeaad188aa9d97dd5baf3b4de5c94 100644 (file)
@@ -127,11 +127,9 @@ def test_cache_methods(r, client, obj):
     attrs = json.loads(output.decode('latin-1'))
 
     assert((data.get(b'user.rgw.tail_tag')) == attrs.get('attrs').get('user.rgw.tail_tag').encode("latin-1") + b'\x00')
-    assert((data.get(b'user.rgw.pg_ver')) == attrs.get('attrs').get('user.rgw.pg_ver').encode("latin-1") + b'\x00\x00\x00\x00\x00\x00\x00')
     assert((data.get(b'user.rgw.idtag')) == attrs.get('tag').encode("latin-1") + b'\x00')
     assert((data.get(b'user.rgw.etag')) == attrs.get('etag').encode("latin-1"))
     assert((data.get(b'user.rgw.x-amz-content-sha256')) == attrs.get('attrs').get('user.rgw.x-amz-content-sha256').encode("latin-1") + b'\x00')
-    assert((data.get(b'user.rgw.source_zone')) == attrs.get('attrs').get('user.rgw.source_zone').encode("latin-1") + b'\x00\x00\x00\x00')
     assert((data.get(b'user.rgw.x-amz-date')) == attrs.get('attrs').get('user.rgw.x-amz-date').encode("latin-1") + b'\x00')
 
     tmp1 = '\x08\x06L\x01\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x06\x84\x00\x00\x00\n\nj\x00\x00\x00\x03\x00\x00\x00bkt+\x00\x00\x00'
index 59fb2d59df562adaebabc8a3529ee24ea0453a62..ffddfe63ee7ba0fd62def8d4acd985545665a548 100644 (file)
@@ -8293,6 +8293,10 @@ next:
         // TODO: decode torrent info for display as json?
         formatter->dump_string("torrent", "<contains binary data>");
         handled = true;
+      } else if (iter->first == RGW_ATTR_PG_VER) {
+        handled = decode_dump<uint64_t>("pg_ver", bl, formatter.get());
+      } else if (iter->first == RGW_ATTR_SOURCE_ZONE) {
+        handled = decode_dump<uint32_t>("source_zone", bl, formatter.get());
       }
 
       if (!handled)