Skip to content
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

fix: state result can be str instead of dict #515

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def conformity(self):

for state in return_item:
# One of the state is not ok
if isinstance(return_item, str):
return False
if not return_item.get(state, {}).get("result"):
return False
return True
Expand Down
6 changes: 5 additions & 1 deletion api/views/alcali.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def conformity_detail(self, request, minion_id):
# Sls error
if isinstance(last_highstate, list):
failed = {"error": last_highstate[0]}
elif isinstance(last_highstate, str):
failed = {"error": last_highstate}
else:
for state in last_highstate:
state_name = state.split("_|-")[1]
Expand Down Expand Up @@ -259,7 +261,9 @@ def render(self, request):
succeeded, unchanged, failed = None, None, 1
else:
for state in last_highstate:
if last_highstate[state]["result"] is True:
if isinstance(last_highstate, str):
failed += 1
elif last_highstate[state]["result"] is True:
succeeded += 1
elif last_highstate[state]["result"] is None:
unchanged += 1
Expand Down
Loading