8000 UX improvement: Displaying the rollback reason after stack goes into failed state by GarisonLotus · Pull Request #687 · cloudtools/stacker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

UX improvement: Displaying the rollback reason after stack goes into failed state #687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion stacker/actions/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,11 @@ def _launch_stack(self, stack, **kwargs):
reason = old_status.reason
if 'rolling' in reason:
reason = reason.replace('rolling', 'rolled')

status_reason = provider.get_rollback_status_reason(stack.fqn)
logger.info(
"%s Stack Roll Back Reason: " + status_reason, stack.fqn)
return FailedStatus(reason)

elif provider.is_stack_completed(provider_stack):
stack.set_outputs(
provider.get_output_dict(provider_stack))
Expand Down
22 changes: 20 additions & 2 deletions stacker/providers/aws/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def _tail_print(e):
e['ResourceType'],
e['EventId']))

def get_events(self, stack_name):
def get_events(self, stack_name, chronological=True):
"""Get the events in batches and return in chronological order"""
next_token = None
event_list = []
Expand All @@ -642,7 +642,25 @@ def get_events(self, stack_name):
if next_token is None:
break
time.sleep(GET_EVENTS_SLEEP)
return reversed(sum(event_list, []))
if chronological:
return reversed(sum(event_list, []))
else:
return sum(event_list, [])

def get_rollback_status_reason(self, stack_name):
"""Process events and returns latest roll back reason"""
event = next((item for item in self.get_events(stack_name,
False) if item["ResourceStatus"] ==
"UPDATE_ROLLBACK_IN_PROGRESS"), None)
if event:
reason = event["ResourceStatusReason"]
return reason
else:
event = next((item for item in self.get_events(stack_name)
if item["ResourceStatus"] ==
"ROLLBACK_IN_PROGRESS"), None)
reason = event["ResourceStatusReason"]
return reason

def tail(self, stack_name, cancel, log_func=_tail_print, sleep_time=5,
include_initial=True):
Expand Down
5 changes: 5 additions & 0 deletions stacker/tests/actions/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,15 @@ def get_stack(name, *args, **kwargs):
'Outputs': [],
'Tags': []}

def get_events(name, *args, **kwargs):
return [{'ResourceStatus': 'ROLLBACK_IN_PROGRESS',
'ResourceStatusReason': 'CFN fail'}]

patch_object(self.provider, 'get_stack', side_effect=get_stack)
patch_object(self.provider, 'update_stack')
patch_object(self.provider, 'create_stack')
patch_object(self.provider, 'destroy_stack')
patch_object(self.provider, 'get_events', side_effect=get_events)

patch_object(self.build_action, "s3_stack_push")

Expand Down
0