← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1804174] Re: horizon fails if the policy file is not found

 

Reviewed:  https://review.openstack.org/618774
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=96912aea91d39c022f60c0758f60c207820578ba
Submitter: Zuul
Branch:    master

commit 96912aea91d39c022f60c0758f60c207820578ba
Author: Sumit Jamgade <sjamgade@xxxxxxxx>
Date:   Mon Nov 19 17:01:44 2018 +0100

    fix checking if enforcer was loaded
    
    enforcer for policy can be loaded from a single file or from multiple
    files (policy_dir). so checking for policy_file is not good enough.
    
    If a policy is loaded it will have some rules, if not loaded then,
    oslo_policy rejects all acccess, but it is not saved to the
    _ENFORCER object, which is holds the objects used for enforcing
    policies. So checking for existance of rules is a better check.
    
    Some refactoring for better logging
    added tests: test_nonexisting_policy_file_load
    
    Change-Id: Id1f65058014ef5b14449b502d6741da9d34767b3
    Closes-Bug: 1804174


** Changed in: horizon
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/1804174

Title:
  horizon fails if the policy file is not found

Status in OpenStack Dashboard (Horizon):
  Fix Released

Bug description:
  Internal Server Error: /project/
  Traceback (most recent call last):
    File "/usr/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
      response = get_response(request)
    File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 217, in _get_response
      response = self.process_exception_by_middleware(e, request)
    File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 215, in _get_response
      response = response.render()
    File "/usr/lib/python2.7/site-packages/django/template/response.py", line 107, in render
      self.content = self.rendered_content
    File "/usr/lib/python2.7/site-packages/django/template/response.py", line 84, in rendered_content
      content = template.render(context, self._request)
    File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 66, in render
      return self.template.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 207, in render
      return self._render(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
      return self.nodelist.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render
      bit = node.render_annotated(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
      return self.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py", line 177, in render
      return compiled_parent._render(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
      return self.nodelist.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render
      bit = node.render_annotated(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
      return self.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py", line 72, in render
      result = block.nodelist.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render
      bit = node.render_annotated(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
      return self.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py", line 72, in render
      result = block.nodelist.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render
      bit = node.render_annotated(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
      return self.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py", line 216, in render
      return template.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 209, in render
      return self._render(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
      return self.nodelist.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render
      bit = node.render_annotated(context)
    File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
      return self.render(context)
    File "/usr/lib/python2.7/site-packages/django/template/library.py", line 225, in render
      _dict = self.func(*resolved_args, **resolved_kwargs)
    File "/usr/lib/python2.7/site-packages/horizon/templatetags/horizon.py", line 74, in horizon_nav
      panel.can_access(context)):
    File "/usr/lib/python2.7/site-packages/horizon/base.py", line 149, in can_access
      return self.allowed(context)
    File "/usr/lib/python2.7/site-packages/horizon/base.py", line 158, in allowed
      return self._can_access(context['request'])
    File "/usr/lib/python2.7/site-packages/horizon/base.py", line 170, in _can_access
      if policy_check(rule_param, request):
    File "/usr/lib/python2.7/site-packages/openstack_auth/policy.py", line 155, in check
      enforcer = _get_enforcer()
    File "/usr/lib/python2.7/site-packages/openstack_auth/policy.py", line 64, in _get_enforcer
      if os.path.isfile(enforcer.policy_path):
    File "/usr/lib64/python2.7/genericpath.py", line 37, in isfile
      st = os.stat(path)
  TypeError: coercing to Unicode: need string or buffer, NoneType found
  Internal Server Error: /project/


  oslo_policy.policy_file can be None which causes this problem

To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/1804174/+subscriptions


References