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

[2015.8] Fix two error conditions in the highstate outputter #30756

Merged
merged 3 commits into from
Feb 1, 2016
Merged
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
19 changes: 17 additions & 2 deletions salt/output/highstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
# Import 3rd-party libs
import salt.ext.six as six

import logging

log = logging.getLogger(__name__)


def output(data):
'''
Expand Down Expand Up @@ -133,7 +137,18 @@ def _format_host(host, data):
# Increment result counts
rcounts.setdefault(ret['result'], 0)
rcounts[ret['result']] += 1
rdurations.append(ret.get('duration', 0))
rduration = ret.get('duration', 0)
try:
float(rduration)
rdurations.append(rduration)
except ValueError:
rduration, _, _ = rduration.partition(' ms')
try:
float(rduration)
rdurations.append(rduration)
except ValueError:
log.error('Cannot parse a float from duration {0}'
.format(ret.get('duration', 0)))

tcolor = colors['GREEN']
schanged, ctext = _format_changes(ret['changes'])
Expand Down Expand Up @@ -230,7 +245,7 @@ def _format_host(host, data):
# be sure that ret['comment'] is utf-8 friendly
try:
if not isinstance(ret['comment'], six.text_type):
ret['comment'] = ret['comment'].decode('utf-8')
ret['comment'] = str(ret['comment']).decode('utf-8')
except UnicodeDecodeError:
# but try to continue on errors
pass
Expand Down