Comment 6 for bug 1620868

Revision history for this message
Aimee Ukasick (aimeeu) wrote :

Confirmed that API and CLI calls to datasource and schema do not return traceback when invalid IDs are passed. "datasource" appears to be the only one of the three displaying user-friendly error information as expected.

openstack congress datasource schema show bad-ds-id
Resource bad-ds-id not found (HTTP 404)
curl -X GET -H "X-Auth-Token: 081efa26afe34c9faf2a229f7ee0f0b2" -H "Cache-Control: no-cache" "http://192.168.56.103:1789/v1/data-sources/bad-ds-id/schema"
{
  "error": {
    "message": "service 'bad-ds-id' could not be found",
    "error_data": null,
    "error_code": 404
  }
}

*****A CLI call to get info about a driver displays a Request-ID
openstack congress driver config show invalid-driver-id
Driver not found None (HTTP 404) (Request-ID: req-17bdab1e-1e71-4d81-8fb3-22dbf859cfbd)
curl -X GET -H "X-Auth-Token: 081efa26afe34c9faf2a229f7ee0f0b2" -H "Cache-Control: no-cache" "http://192.168.56.103:1789/v1/system/drivers/invalid-driver-id"
{
  "error": {
    "message": "Driver not found None",
    "error_data": null,
    "error_code": 404
  }
}

*****The error/not found handling for policies seems to be inconsistent. The first two examples below return a 404. The third: the CLI returns HTTP 400 but the API returns and error code of 1020 (which maps to HTTP 404)

curl -X GET -H "X-Auth-Token: 5a3b135235e045049a8f883370c675c0" -H "Cache-Control: no-cache" "http://192.168.56.103:1789/v1/policies/bad-policy-id"
{
  "error": {
    "message": "Not Found::No policy found with name or id bad-policy-id\nTraceback (most recent call last):\n\n File \"/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/server.py\", line 133, in _process_incoming\n res = self.dispatcher.dispatch(message)\n\n File \"/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py\", line 150, in dispatch\n return self._do_dispatch(endpoint, method, ctxt, args)\n\n File \"/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py\", line 121, in _do_dispatch\n result = func(ctxt, **new_args)\n\n File \"/opt/stack/congress/congress/policy_engines/agnostic.py\", line 2318, in persistent_get_policy\n return self.dse.persistent_get_policy(id_)\n\n File \"/opt/stack/congress/congress/policy_engines/agnostic.py\", line 398, in persistent_get_policy\n 'No policy found with name or id %s' % id_)\n\nNotFound: No policy found with name or id bad-policy-id\n",
    "error_data": null,
    "error_code": 404
  }
}

openstack congress policy row list bob p
Not Found::table 'p' doesn't exist
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/server.py", line 133, in _process_incoming
    res = self.dispatcher.dispatch(message)
  File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 150, in dispatch
    return self._do_dispatch(endpoint, method, ctxt, args)
  File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 121, in _do_dispatch
    result = func(ctxt, **new_args)
  File "/opt/stack/congress/congress/policy_engines/agnostic.py", line 2362, in get_row_data
    return self.dse.get_row_data(table_id, source_id, trace)
  File "/opt/stack/congress/congress/policy_engines/agnostic.py", line 894, in get_row_data
    raise KeyError("Table '%s' doesn't exist" % table_id)
NotFound: table 'p' doesn't exist
 (HTTP 404) (Request-ID: req-e0fe5485-1b2c-4f25-8d2c-55f8be9a4269)
curl -X GET -H "X-Auth-Token: 5a3b135235e045049a8f883370c675c0" -H "Cache-Control: no-cache" "http://192.168.56.103:1789/v1/policies/bad-policy-id/tables/bad-table-id/rows"
{
  "error": {
    "message": "Not Found::Table 'bad-table-id' doesn't exist\nTraceback (most recent call last):\n\n File \"/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/server.py\", line 133, in _process_incoming\n res = self.dispatcher.dispatch(message)\n\n File \"/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py\", line 150, in dispatch\n return self._do_dispatch(endpoint, method, ctxt, args)\n\n File \"/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py\", line 121, in _do_dispatch\n result = func(ctxt, **new_args)\n\n File \"/opt/stack/congress/congress/policy_engines/agnostic.py\", line 2365, in get_row_data\n return self.dse.get_row_data(table_id, source_id, trace)\n\n File \"/opt/stack/congress/congress/policy_engines/agnostic.py\", line 896, in get_row_data\n raise exception.NotFound(m)\n\nNotFound: Table 'bad-table-id' doesn't exist\n",
    "error_data": null,
    "error_code": 404
  }
}

openstack congress policy rule list bad-policy-name
The specified policy does not exist.::Policy ID bad-policy-name does not exist
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/server.py", line 133, in _process_incoming
    res = self.dispatcher.dispatch(message)
  File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 150, in dispatch
    return self._do_dispatch(endpoint, method, ctxt, args)
  File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 121, in _do_dispatch
    result = func(ctxt, **new_args)
  File "/opt/stack/congress/congress/policy_engines/agnostic.py", line 2332, in persistent_get_rules
    return self.dse.persistent_get_rules(policy_name)
  File "/opt/stack/congress/congress/policy_engines/agnostic.py", line 415, in persistent_get_rules
    self.assert_policy_exists(policy_name)
  File "/opt/stack/congress/congress/policy_engines/agnostic.py", line 672, in assert_policy_exists
    name='policy_not_exist')
PolicyRuntimeException: Policy ID bad-policy-name does not exist
 (HTTP 400) (Request-ID: req-ea213899-bbe4-4cf5-8215-f64451df9130)

curl -X GET -H "X-Auth-Token: 081efa26afe34c9faf2a229f7ee0f0b2" -H "Cache-Control: no-cache" "http://192.168.56.103:1789/v1/policies/bad-policy-id/rules"
{
  "error": {
    "message": "The specified policy does not exist.::Policy ID bad-policy-id does not exist\nTraceback (most recent call last):\n\n File \"/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/server.py\", line 133, in _process_incoming\n res = self.dispatcher.dispatch(message)\n\n File \"/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py\", line 150, in dispatch\n return self._do_dispatch(endpoint, method, ctxt, args)\n\n File \"/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py\", line 121, in _do_dispatch\n result = func(ctxt, **new_args)\n\n File \"/opt/stack/congress/congress/policy_engines/agnostic.py\", line 2332, in persistent_get_rules\n return self.dse.persistent_get_rules(policy_name)\n\n File \"/opt/stack/congress/congress/policy_engines/agnostic.py\", line 415, in persistent_get_rules\n self.assert_policy_exists(policy_name)\n\n File \"/opt/stack/congress/congress/policy_engines/agnostic.py\", line 672, in assert_policy_exists\n name='policy_not_exist')\n\nPolicyRuntimeException: Policy ID bad-policy-id does not exist\n",
    "error_data": null,
    "error_code": 1020
  }
}