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

Set state_output_profile as option and update docs #59165

Merged
merged 7 commits into from
Feb 23, 2021
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
4 changes: 4 additions & 0 deletions conf/master
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,10 @@
# states is cluttering the logs. Set it to True to ignore them.
#state_output_diff: False

# The state_output_profile setting changes whether profile information
# will be shown for each state run.
#state_output_profile: True

# Automatically aggregate all states that have support for mod_aggregate by
# setting to 'True'. Or pass a list of state module names to automatically
# aggregate just those types.
Expand Down
14 changes: 14 additions & 0 deletions doc/ref/configuration/master.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,20 @@ states is cluttering the logs. Set it to True to ignore them.

state_output_diff: False

.. conf_master:: state_output_profile

``state_output_profile``
------------------------

Default: ``True``

The ``state_output_profile`` setting changes whether profile information
will be shown for each state run.

.. code-block:: yaml

state_output_profile: True

.. conf_master:: state_aggregate

``state_aggregate``
Expand Down
14 changes: 14 additions & 0 deletions doc/ref/configuration/minion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,20 @@ states is cluttering the logs. Set it to True to ignore them.

state_output_diff: False

.. conf_minion:: state_output_profile

``state_output_profile``
------------------------

Default: ``True``

The ``state_output_profile`` setting changes whether profile information
will be shown for each state run.

.. code-block:: yaml

state_output_profile: True

.. conf_minion:: autoload_dynamic_modules

``autoload_dynamic_modules``
Expand Down
4 changes: 4 additions & 0 deletions salt/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ def _gather_buffer_space():
"state_output": str,
# Tells the highstate outputter to only report diffs of states that changed
"state_output_diff": bool,
# Tells the highstate outputter whether profile information will be shown for each state run
"state_output_profile": bool,
# When true, states run in the order defined in an SLS file, unless requisites re-order them
"state_auto_order": bool,
# Fire events as state chunks are processed by the state compiler
Expand Down Expand Up @@ -1142,6 +1144,7 @@ def _gather_buffer_space():
"state_verbose": True,
"state_output": "full",
"state_output_diff": False,
"state_output_profile": True,
"state_auto_order": True,
"state_events": False,
"state_aggregate": False,
Expand Down Expand Up @@ -1473,6 +1476,7 @@ def _gather_buffer_space():
"state_verbose": True,
"state_output": "full",
"state_output_diff": False,
"state_output_profile": True,
"state_auto_order": True,
"state_events": False,
"state_aggregate": False,
Expand Down
11 changes: 4 additions & 7 deletions salt/output/highstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,13 @@
Total: 0
"""

# Import python libs

import logging
import pprint
import re
import textwrap

import salt.output

# Import salt libs
import salt.utils.color
import salt.utils.data
import salt.utils.stringutils
Expand Down Expand Up @@ -356,7 +353,7 @@ def _format_host(host, data, indent_level=1):
" {tcolor} Result: {ret[result]!s}{colors[ENDC]}",
" {tcolor} Comment: {comment}{colors[ENDC]}",
]
if __opts__.get("state_output_profile", True) and "start_time" in ret:
if __opts__.get("state_output_profile") and "start_time" in ret:
state_lines.extend(
[
" {tcolor} Started: {ret[start_time]!s}{colors[ENDC]}",
Expand Down Expand Up @@ -498,7 +495,7 @@ def _counts(label, count):
)
hstrs.append(colorfmt.format(colors["CYAN"], totals, colors))

if __opts__.get("state_output_profile", True):
if __opts__.get("state_output_profile"):
sum_duration = sum(rdurations)
duration_unit = "ms"
# convert to seconds if duration is 1000ms or more
Expand Down Expand Up @@ -570,7 +567,7 @@ def _format_terse(tcolor, comps, ret, colors, tabular):
c=colors, w="\n".join(ret["warnings"])
)
fmt_string += "{0}"
if __opts__.get("state_output_profile", True) and "start_time" in ret:
if __opts__.get("state_output_profile") and "start_time" in ret:
fmt_string += "{6[start_time]!s} [{6[duration]!s:>7} ms] "
fmt_string += "{2:>10}.{3:<10} {4:7} Name: {1}{5}"
elif isinstance(tabular, str):
Expand All @@ -582,7 +579,7 @@ def _format_terse(tcolor, comps, ret, colors, tabular):
c=colors, w="\n".join(ret["warnings"])
)
fmt_string += " {0} Name: {1} - Function: {2}.{3} - Result: {4}"
if __opts__.get("state_output_profile", True) and "start_time" in ret:
if __opts__.get("state_output_profile") and "start_time" in ret:
fmt_string += " Started: - {6[start_time]!s} Duration: {6[duration]!s} ms"
fmt_string += "{5}"

Expand Down
16 changes: 2 additions & 14 deletions tests/unit/output/test_highstate.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
# -*- coding: utf-8 -*-
"""
unittests for highstate outputter
"""

# Import Python Libs
from __future__ import absolute_import

import salt.output.highstate as highstate

# Import Salt Libs
import salt.utils.stringutils

# Import 3rd-party libs
from salt.ext import six

# Import Salt Testing Libs
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import TestCase

Expand Down Expand Up @@ -125,10 +115,7 @@ def test_output_comment_is_not_unicode(self):
entry = self.data[key]
continue
entry = entry[key]
if six.PY2:
entry["comment"] = salt.utils.stringutils.to_unicode(entry["comment"])
else:
entry["comment"] = salt.utils.stringutils.to_bytes(entry["comment"])
entry["comment"] = salt.utils.stringutils.to_bytes(entry["comment"])
ret = highstate.output(self.data)
self.assertIn("Succeeded: 1 (changed=1)", ret)
self.assertIn("Failed: 0", ret)
Expand All @@ -148,6 +135,7 @@ def setup_loader_modules(self):
"__opts__": {
"extension_modules": "",
"color": False,
"state_output_profile": True,
"optimization_order": [0, 1, 2],
}
}
Expand Down