Skip to content

Commit

Permalink
Fix the error when monitor calls _is_admin with context not available
Browse files Browse the repository at this point in the history
Catch the runtime error and return False as the monitor will not have a context and it needs to relocate the host which is reservable - so return false
  • Loading branch information
AnishReddyRavula committed Nov 20, 2023
1 parent a93f0d0 commit 076c1b1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion blazar/plugins/oshosts/host_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,11 @@ def allocation_candidates(self, values):
return host_ids

def _is_admin(self):
ctx = context.current()
try:
# when monitor calls this will raise an error
ctx = context.current()
except RuntimeError:
return False
if policy.enforce(ctx, 'admin', {}, do_raise=False):
return True
else:
Expand Down

0 comments on commit 076c1b1

Please sign in to comment.