Status code missing in case of quota exception

Bug #1187698 reported by Andrea Frittoli on 2013-06-05
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

When getting a network quota exception like follows:

DEBUG: quantumclient.client RESP:{'date': 'Wed, 05 Jun 2013 09:02:11 GMT', 'status': '409', 'connection': 'close', 'content-type': 'application/json', 'content-length': '61'} {"QuantumError": "Quota exceeded for resources: ['network']"}

The status code returned by the binding is 0.
The error_dict built by the code below in is actually a string "Quota exceeded for resources: ['network']".
Thus it ends-up in the else case below, which does not pass the status_code along.

I think there are two problems with the code here:
- the quota exception shall be recognized properly
- the else case shall pass the status code anyways

The same issue applies to port and subnet quotas.

    if error_dict:
        # If QuantumError key is found, it will definitely contain
        # a 'message' and 'type' keys?
            error_type = error_dict['type']
            error_message = (error_dict['message'] + "\n" +
        except Exception:
            bad_quantum_error_flag = True
        if not bad_quantum_error_flag:
            ex = None
                # raise the appropriate error!
                ex = quantum_errors[error_type](message=error_message)
                ex.args = ([dict(status_code=status_code,
                                 message=error_message)], )
            except Exception:
            if ex:
                raise ex
            raise exceptions.QuantumClientException(message=error_dict)

summary: - Status code missing in case of network quota exception
+ Status code missing in case of quota exception
description: updated
Jordan Pittier (jordan-pittier) wrote :

Yep I confirm this.

But I think it is wider than this. It seems to me there's a problem with how exception are handled in Quantum server and python-quantum-client.

The assumption in the commentary " # If QuantumError key is found, it will definitely contain a 'message' and 'type' keys?" does not hold anymore, I think. If you look how quantum server Exception are built (quantum/api/v2/ body = serializer.serialize({'QuantumError': e}). e could be one of the exception defined in (quantum/common/ There's not mention to 'detail' or 'type' anymore.

In other word, I can't figure out how could the flag bad_quantum_error_flag stay set to "false".

Akihiro Motoki (amotoki) wrote :

As of Dec 2015, it is now fixed. After the bug was reported, I made refactoring of neutronclient exception so that we can map an exception from neturon API more easily. I think it was fixed as a part of the refactoring.

In [5]: nc = client.Client(username='demo', password='cloudstack-wakame-aws', auth_url='', tenant_name='demo')

In [6]: try:
   ...: nc.create_network({'network': {'name': 'testnet'}})
   ...: except Exception as e:
   ...: exc = e

In [7]: exc.status_code
Out[7]: 409

In [8]: print(e)
Quota exceeded for resources: ['network'].

Changed in python-neutronclient:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers