Non-JSON policy file causing failure to load policy

Bug #1177365 reported by git-harry on 2013-05-07
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Wishlist
Unassigned

Bug Description

If the file /etc/glance/policy.json is not valid JSON data an unhandled exception is raised by the JSON decoder.

$ glance image-list
Request returned failure status.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 383, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/stack/glance/glance/common/wsgi.py", line 367, in __call__
    response = req.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1296, in send
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1260, in call_application
    app_iter = application(self.environ, start_response)
  File "/opt/stack/python-keystoneclient/keystoneclient/middleware/auth_token.py", line 451, in __call__
    return self.app(env, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/stack/glance/glance/common/wsgi.py", line 364, in __call__
    response = self.process_request(req)
  File "/opt/stack/glance/glance/api/middleware/context.py", line 79, in process_request
    req.context = self._get_authenticated_context(req)
  File "/opt/stack/glance/glance/api/middleware/context.py", line 125, in _get_authenticated_context
    return glance.context.RequestContext(**kwargs)
  File "/opt/stack/glance/glance/context.py", line 46, in __init__
    self.policy_enforcer.check_is_admin(self)
  File "/opt/stack/glance/glance/api/policy.py", line 155, in check_is_admin
    return self.check(context, 'context_is_admin', target)
  File "/opt/stack/glance/glance/api/policy.py", line 145, in check
    return self._check(context, action, target)
  File "/opt/stack/glance/glance/api/policy.py", line 115, in _check
    self.load_rules()
  File "/opt/stack/glance/glance/api/policy.py", line 67, in load_rules
    rules = self._read_policy_file()
  File "/opt/stack/glance/glance/api/policy.py", line 99, in _read_policy_file
    rules_dict = json.loads(raw_contents)
  File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
 (HTTP 500)

git-harry (git-harry) on 2013-05-07
Changed in glance:
assignee: nobody → git-harry (git-harry)

Fix proposed to branch: master
Review: https://review.openstack.org/28413

Changed in glance:
status: New → In Progress
Changed in glance:
importance: Undecided → Low
Erno Kuvaja (jokke) on 2014-09-12
Changed in glance:
status: In Progress → New
assignee: git-harry (git-harry) → nobody
Changed in glance:
assignee: nobody → agileclipse (agileclipse)
Louis Taylor (kragniz) on 2014-11-17
Changed in glance:
importance: Low → Wishlist
status: New → Confirmed
Kamil Rykowski (kamil-rykowski) wrote :

I guess that the issue has been solved by moving to the oslo_policy. Right now if there is an error inside policy file, oslo will raise an exception with information about what happened and what is wrong with the policy.json eg:

ValueError: Expecting ',' delimiter: line 5 column 5 (char 64)

Ian Cordasco (icordasc) on 2015-05-23
Changed in glance:
assignee: agileclipse (agileclipse) → nobody
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers