diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2018-06-20 18:00:08 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2018-06-20 18:00:08 +0100 |
commit | 33c6611c2a6669dc3b04e76b7013d577fe39cff6 (patch) | |
tree | 7b33ccc8f8a2b59457bff2fe09ee98479f7fccc8 | |
parent | 4ca1ee26b60f254dd65f8d8744e05d5ac12a3bdd (diff) | |
download | sos-33c6611c2a6669dc3b04e76b7013d577fe39cff6.tar.gz |
[Plugin] set size limits automatically
If the caller does not specific an explicit size limit (or 0 to
disable limits) automatically set the sizelimit argument for the
add_copy_spec(), add_cmd_output(), and add_journal() methods to
the value of the "log_size" option.
Resolves: #1325
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/__init__.py | 11 | ||||
-rw-r--r-- | tests/plugin_tests.py | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index b1c225db..2920030f 100644 --- a/sos/plugins/__init__.py +++ b/sos/plugins/__init__.py @@ -539,6 +539,7 @@ class Plugin(object): a single file the file will be tailed to meet sizelimit. If the first file in a glob is too large it will be tailed to meet the sizelimit. """ + sizelimit = sizelimit or self.get_option("log_size") if self.get_option('all_logs'): sizelimit = None @@ -672,6 +673,7 @@ class Plugin(object): cmds = [cmds] if len(cmds) > 1 and (suggest_filename or root_symlink): self._log_warn("ambiguous filename or symlink for command list") + sizelimit = sizelimit or self.get_option("log_size") for cmd in cmds: self._add_cmd_output(cmd, suggest_filename=suggest_filename, root_symlink=root_symlink, timeout=timeout, @@ -831,6 +833,15 @@ class Plugin(object): identifier_opt = " --identifier %s" catalog_opt = " --catalog" + journal_size = 100 + + sizelimit = sizelimit or self.get_option("log_size") + if not sizelimit or int(sizelimit) < journal_size: + sizelimit = journal_size + + if self.get_option('all_logs'): + sizelimit = None + if isinstance(units, six.string_types): units = [units] diff --git a/tests/plugin_tests.py b/tests/plugin_tests.py index 60d59d6f..c03e313e 100644 --- a/tests/plugin_tests.py +++ b/tests/plugin_tests.py @@ -92,6 +92,7 @@ class EnablerPlugin(Plugin): class MockOptions(object): all_logs = False + log_size = 25 class PluginToolTests(unittest.TestCase): |