Non-JSON policy file causing failure to load policy

Bug #1177365 reported by git-harry
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Won't Fix
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)
Changed in glance:
assignee: nobody → git-harry (git-harry)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (master)

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)
Changed in glance:
status: In Progress → New
assignee: git-harry (git-harry) → nobody
Changed in glance:
assignee: nobody → agileclipse (agileclipse)
Louis Taylor (kragniz)
Changed in glance:
importance: Low → Wishlist
status: New → Confirmed
Revision history for this message
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)
Changed in glance:
assignee: agileclipse (agileclipse) → nobody
Revision history for this message
Cyril Roelandt (cyril-roelandt) wrote :

We are no longer using JSON policy files, so I'll close this.

Changed in glance:
status: Confirmed → Won't Fix
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.