]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ceph_json: dump bool using f->dump_bool() 45835/head
authorKefu Chai <tchaikov@gmail.com>
Sun, 10 Apr 2022 01:23:59 +0000 (09:23 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sat, 21 May 2022 08:32:14 +0000 (16:32 +0800)
as per https://www.json.org/json-en.html, JSON encodes bool as
"true" or "false", without the quotes. before this change, the quotes
are always added when encoding boolean values.

but this change is not backward compatible.

encode_json()'s bool overload is used by rgw. it uses JSONObj
defined in common/ceph_json.h to decode JSON-encoded structs.
and it does not differentiate bool from str when decoding a boolean
value despite that it could have check the "quoted" member variable
of JSONObj for validating the type of value. so we should be fine.

Fixes: https://tracker.ceph.com/issues/55189
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
PendingReleaseNotes
doc/radosgw/pubsub-module.rst
src/common/ceph_json.cc
src/pybind/mgr/dashboard/services/rgw_client.py

index 7f4381b34455c98c648f0602176c3c289f485ea5..19833faafcbf3bc13d28878b812f30e4e7bb860b 100644 (file)
@@ -5,3 +5,41 @@
   defaults to "/var/log/ceph/ops-log-$cluster-$name.log".
 * The SPDK backend for BlueStore is now able to connect to an NVMeoF target.
   Please note that this is not an officially supported feature.
+* RGW's pubsub interface now returns boolean fields using bool. Before this change,
+  `/topics/<topic-name>` returns "stored_secret" and "persistent" using a string
+  of "true" or "false" with quotes around them. After this change, these fields
+  are returned without quotes so they can be decoded as boolean values in JSON.
+  The same applies to the `is_truncated` field returned by `/subscriptions/<sub-name>`.
+* RGW's response of `Action=GetTopicAttributes&TopicArn=<topic-arn>` REST API now
+  returns `HasStoredSecret` and `Persistent` as boolean in the JSON string
+  encoded in `Attributes/EndPoint`.
+* All boolean fields previously rendered as string by `rgw-admin` command when
+  the JSON format is used are now rendered as boolean. If your scripts/tools
+  relies on this behavior, please update them accordingly. The impacted field names
+  are:
+  * absolute
+  * add
+  * admin
+  * appendable
+  * bucket_key_enabled
+  * delete_marker
+  * exists
+  * has_bucket_info
+  * high_precision_time
+  * index
+  * is_master
+  * is_prefix
+  * is_truncated
+  * linked
+  * log_meta
+  * log_op
+  * pending_removal
+  * read_only
+  * retain_head_object
+  * rule_exist
+  * start_with_full_sync
+  * sync_from_all
+  * syncstopped
+  * system
+  * truncated
+  * user_stats_sync
index a7e3b3a6e4aec229a103ac1eaa7f6e7ea8adc778..47e44661097dc92c9ca1307c13f019c056bdcd26 100644 (file)
@@ -280,8 +280,8 @@ Response will have the following format (JSON):
                "push_endpoint":"",
                "push_endpoint_args":"",
                "push_endpoint_topic":"",
-               "stored_secret":"",
-               "persistent":""
+               "stored_secret":false,
+               "persistent":true,
            },
            "arn":""
            "opaqueData":""
@@ -519,7 +519,7 @@ The response will hold information on the current marker and whether there are m
 
 ::
 
-   {"next_marker":"","is_truncated":"",...}
+   {"next_marker":"","is_truncated":false,...}
 
 
 The actual content of the response is depended with how the subscription was created.
index b5f8756718b0fabc52bcd42efaada32cf619f047..3270d2c49b07c9ca7a6dff82b751ac891db8929b 100644 (file)
@@ -531,13 +531,7 @@ void encode_json(const char *name, const char *val, Formatter *f)
 
 void encode_json(const char *name, bool val, Formatter *f)
 {
-  string s;
-  if (val)
-    s = "true";
-  else
-    s = "false";
-
-  f->dump_string(name, s);
+  f->dump_bool(name, val);
 }
 
 void encode_json(const char *name, int val, Formatter *f)
index d7cff2fa0557eba0ae6ffca571fc59cf3a21e6fa..14a4b7750ddd0729ea11e2249ddcec457d1a7b79 100644 (file)
@@ -5,7 +5,6 @@ import json
 import logging
 import re
 import xml.etree.ElementTree as ET  # noqa: N814
-from distutils.util import strtobool
 from subprocess import SubprocessError
 
 from mgr_util import build_url
@@ -467,7 +466,7 @@ class RgwClient(RestClient):
     def _is_system_user(self, admin_path, userid, request=None) -> bool:
         # pylint: disable=unused-argument
         response = request()
-        return strtobool(response['data']['system'])
+        return response['data']['system']
 
     def is_system_user(self) -> bool:
         return self._is_system_user(self.admin_path, self.userid)