From 076c1b17b4271f779331a6b84a2186bfa0531092 Mon Sep 17 00:00:00 2001 From: Anish Reddy Ravula <2anishreddy@gmail.com> Date: Mon, 20 Nov 2023 16:40:11 -0600 Subject: [PATCH] Fix the error when monitor calls _is_admin with context not available 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 --- blazar/plugins/oshosts/host_plugin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blazar/plugins/oshosts/host_plugin.py b/blazar/plugins/oshosts/host_plugin.py index c98d7a59..d6a75e3b 100644 --- a/blazar/plugins/oshosts/host_plugin.py +++ b/blazar/plugins/oshosts/host_plugin.py @@ -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: