quota: invalid JSON for reservation value when positive

Bug #1918565 reported by Emilien Macchi
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
High
Matthew Booth

Bug Description

# High level description

When a resource (e.g. port) is requested, QuotaDetail returns invalid JSON until all resources of that type are created (e.g. all ports requested are now created and there is no ongoing request to create any other port). The invalid JSON is only for the "reserved" key, which returns a string instead of an integer.

This is incompatible with what the API is supposed to return:
https://docs.openstack.org/api-ref/network/v2/index.html?expanded=show-quota-details-for-a-tenant-detail

"The value for each resource type is itself an object (the quota set) containing the quota’s used, limit and reserved integer values."

It is problematic in the context of gophercloud, which expect an integer to be returned, and not a string:
https://github.com/gophercloud/gophercloud/blob/cd9c207e93f4f76af2c0a06c6d449ab342bfbe56/openstack/networking/v2/extensions/quotas/results.go#L125

# Pre-conditions

* Neutron QuotaDB driver is used.
* Resources have to be under creation (e.g. ports)

# Step-by-step reproduction steps

* Get a token from Keystone:
$ openstack token issue

And export its ID as $token.

* Run this loop:
$ while true; do curl -H "X-Auth-Token: $token" <your-neutron-endpoint>:9696/v2.0/quotas/<your-project-id>/details.json | jq '.'|& tee -a logs; done

* In another terminal, run this command:
$ tail -f logs|grep 'reserved": "'

* Now, create ports (e.g. 3 ports)
$ openstack port create (...)

* Expected output

{
  "quota": {
    "port": {
      "limit": 500,
      "used": 0,
      "reserved": 3
    },
...
}

Then:

{
  "quota": {
    "port": {
      "limit": 500,
      "used": 1,
      "reserved": 2
    },
...
}

Then:

{
  "quota": {
    "port": {
      "limit": 500,
      "used": 2,
      "reserved": 1
    },
...
}

And then:

{
  "quota": {
    "port": {
      "limit": 500,
      "used": 3,
      "reserved": 0
    },
...
}

* Actual output

{
  "quota": {
    "port": {
      "limit": 500,
      "used": 0,
      "reserved": "3"
    },
...
}

Then:

{
  "quota": {
    "port": {
      "limit": 500,
      "used": 1,
      "reserved": "2"
    },
...
}

Then:

{
  "quota": {
    "port": {
      "limit": 500,
      "used": 2,
      "reserved": "1"
    },
...
}

And then:

{
  "quota": {
    "port": {
      "limit": 500,
      "used": 3,
      "reserved": 0 // an integer!
    },
...
}

# Version:

Master and stable branches.
RHEL 8.3
TripleO based deployment (OSP 17)

# Environment:
OSP17 deployed in standalone, OVN backend.

# Perceived severity:
Workaround is possible but currently blocking gophercloud to be working for QuotaDetails.

Tags: db
summary: - quota: invalid JSON for reservation data
+ quota: invalid JSON for reservation value when positive
Revision history for this message
Brian Haley (brian-haley) wrote :

I confirmed via the above scripting this happens:

      "reserved": 0
      "reserved": 0
      "reserved": 0
      "reserved": "1"
      "reserved": 0
      "reserved": 0

https://review.opendev.org/c/openstack/neutron/+/779878 was started to fix it.

tags: added: db
Changed in neutron:
status: New → Confirmed
importance: Undecided → High
Changed in neutron:
assignee: nobody → Matthew Booth (mbooth-9)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 18.0.0.0rc1

This issue was fixed in the openstack/neutron 18.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 15.3.4

This issue was fixed in the openstack/neutron 15.3.4 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 16.3.2

This issue was fixed in the openstack/neutron 16.3.2 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 17.1.2

This issue was fixed in the openstack/neutron 17.1.2 release.

tags: added: neutron-proactive-backport-potential
Revision history for this message
Bernard Cafarelli (bcafarel) wrote :

Fix is backported up to rocky (included)

tags: removed: neutron-proactive-backport-potential
Changed in neutron:
status: Confirmed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron queens-eol

This issue was fixed in the openstack/neutron queens-eol release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron rocky-eol

This issue was fixed in the openstack/neutron rocky-eol release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron stein-eol

This issue was fixed in the openstack/neutron stein-eol release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.