From 2ea501c069c23b534d9f8fa5f5782def784e4db1 Mon Sep 17 00:00:00 2001 From: Artom Lifshitz Date: Fri, 30 Aug 2024 09:56:16 -0400 Subject: [PATCH] stack event loops: handle get None result We've seen at least one case in CI of `stack` being None when polling for stack events: File "openstack/cloud/_orchestration.py", line 185, in delete_stack event_utils.poll_for_events( File "openstack/orchestration/util/event_utils.py", line 109, in poll_for_events stack_status = stack['stack_status'] TypeError: 'NoneType' object is not subscriptable Handle this case with a simple if. Change-Id: Icce6e7b600125cf98e56d98e1c3df4177414398b --- openstack/orchestration/util/event_utils.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openstack/orchestration/util/event_utils.py b/openstack/orchestration/util/event_utils.py index c84a550c3..4e079f4e0 100644 --- a/openstack/orchestration/util/event_utils.py +++ b/openstack/orchestration/util/event_utils.py @@ -106,11 +106,12 @@ def poll_for_events( if no_event_polls >= 2: # after 2 polls with no events, fall back to a stack get stack = cloud.get_stack(stack_name, resolve_outputs=False) - stack_status = stack['stack_status'] - msg = msg_template % dict(name=stack_name, status=stack_status) - if stop_check(stack_status): - return stack_status, msg - # go back to event polling again - no_event_polls = 0 + if stack: + stack_status = stack['stack_status'] + msg = msg_template % dict(name=stack_name, status=stack_status) + if stop_check(stack_status): + return stack_status, msg + # go back to event polling again + no_event_polls = 0 time.sleep(poll_period)