neutron/neutron
Matthew Booth c3ffac8200 Fix invalid JSON generated by quota details
The value fetched by Quotasv2_detail.get_resources() is ultimately
returned by Reservation.get_total_reservations_map. The total_reserved
value is returned by a sqlalchemy sum(), and is of a type defined by
the database driver in use. PyMySQL returns a Decimal here, which
the api layer serialises to JSON as a string.

Note that if a resource has no reservations then its value will be
defaulted in DbQuotaDriver.get_detailed_tenant_quotas to the integer
value 0. This means that the value is an integer if zero, or a string
otherwise. This causes parsing difficulties for client libraries which
do strict type checking.

Testing note:
This method is already covered by the unit test
TestQuotaDbApi.test_get_reservations_for_resource, which also already
tests the return value and, implicitly, its type. However, it does not
currently fail because the unit tests run with SQLite rather than MySQL.
SQLite returns an int where MySQL returns a Decimal, which does not
trigger the bug.

TestQuotaDbApi.test_get_reservations_for_resource is sufficient to
demonstrate that the patch doesn't regress SQLite. We were not able to
think of a deterministic way to write a Tempest test for this, which
would cover MySQL. Ideally we would have the ability to run the DB test
suites under MySQL and PostreSQL in addition to SQLite using oslo.db's
OpportunisticDbFixture, but the scope of that is larger than this
change.

Closes-Bug: #1918565
Change-Id: Icda0d63f2f5ea72bde423296c76aa46646fa98a8
(cherry picked from commit 9ed17cec2d)
2021-03-19 15:03:07 +00:00
..
agent Merge "[OVS FW] Clean conntrack entries with mark == CT_MARK_INVALID" into stable/victoria 2021-03-13 01:26:48 +00:00
api Process DHCP events in order if related 2021-02-07 10:04:58 +00:00
cmd Fix calling of add_tunnel_port method from sanity checks module 2020-12-03 08:34:00 +00:00
common [OVN] Set mcast_flood_reports on LSPs 2021-03-10 10:33:58 +00:00
conf Merge "[OVN][OVS] Different metadata_workers default based on driver" 2020-09-09 18:40:03 +00:00
core_extensions Remove usage of six.add_metaclass 2020-05-21 14:41:18 -04:00
db Revert "DVR: Remove control plane arp updates for DVR" 2021-03-09 13:07:17 +00:00
debug Fix neutron debug probe to use integration_bridge 2020-03-31 11:17:47 +00:00
extensions Add source_ip_prefix and destination_ip_prefix to metering label rules 2020-09-30 12:26:01 +00:00
hacking Remove "six" library 2020-07-28 16:55:52 +00:00
ipam Bump pylint version to support python 3.8 2020-08-06 16:00:30 +02:00
locale Imported Translations from Zanata 2020-05-03 07:38:11 +00:00
notifiers Add config option ``http_retries`` 2020-06-29 22:07:46 -04:00
objects Fix invalid JSON generated by quota details 2021-03-19 15:03:07 +00:00
pecan_wsgi Remove "six" library 2020-07-28 16:55:52 +00:00
plugins [OVN] Set mcast_flood_reports on LSPs 2021-03-10 10:33:58 +00:00
privileged Fix dhcp_release when client_id is specified 2020-10-02 14:53:10 +00:00
profiling Remove "six" library 2020-07-28 16:55:52 +00:00
quota Remove "six" library 2020-07-28 16:55:52 +00:00
scheduler L3 agent scheduler should return a valid index if manual scheduling 2020-06-24 15:37:23 +00:00
server Re-use existing ProcessLauncher from wsgi in RPC workers 2020-02-07 14:51:06 +01:00
services Add minimum bw qos rule validation for network 2021-03-04 14:30:58 +00:00
tests Merge "[OVS FW] Clean conntrack entries with mark == CT_MARK_INVALID" into stable/victoria 2021-03-13 01:26:48 +00:00
__init__.py Remove usage of six.PY2 2020-05-22 12:59:01 -04:00
_i18n.py Make code follow log translation guideline 2017-08-14 02:01:48 +00:00
auth.py
manager.py Remove usage of six.add_metaclass 2020-05-21 14:41:18 -04:00
neutron_plugin_base_v2.py Remove usage of six.add_metaclass 2020-05-21 14:41:18 -04:00
opts.py No rpc_response_max_timeout in LB-agent 2020-06-01 15:25:20 +00:00
policy.py Remove usage of six.text_type and six.string_type 2020-05-22 14:02:55 -04:00
service.py Re-use existing ProcessLauncher from wsgi in RPC workers 2020-02-07 14:51:06 +01:00
version.py
worker.py Change process name of neutron-server to match worker role 2019-03-01 14:18:09 -05:00
wsgi.py Remove usage of six.text_type and six.string_type 2020-05-22 14:02:55 -04:00