From afef09ccbaa19f63cb8d498b37d7431abda8201f Mon Sep 17 00:00:00 2001 From: Stanislav Levin Date: Wed, 19 May 2021 12:03:06 +0300 Subject: [PATCH] ipatests: Ignore warnings on failed to read files on tarring There are tons of useless warnings about missing files on collecting logs, such as: ``` tar: /var/log/ipaserver-kra-install.log: Warning: Cannot stat: No such file or directory tar: /var/log/ipaepn.log: Warning: Cannot stat: No such file or directory tar: /etc/NetworkManager/NetworkManager.conf: Warning: Cannot stat: No such file or directory tar: /var/log/ipabackup.log: Warning: Cannot stat: No such file or directory tar: /var/log/iparestore.log: Warning: Cannot stat: No such file or directory ... ``` Since `--ignore-failed-read` option is passed to tar the caller doesn't care about not readable(mostly missing) files and these warnings may be filtered out. This improves the readability of test logs. Reviewed-By: Alexander Bokovoy --- ipatests/azure/scripts/azure-run-base-tests.sh | 1 + ipatests/azure/templates/test-jobs.yml | 2 +- ipatests/pytest_ipa/integration/__init__.py | 14 +++++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ipatests/azure/scripts/azure-run-base-tests.sh b/ipatests/azure/scripts/azure-run-base-tests.sh index e32a67db0..3d5346f17 100755 --- a/ipatests/azure/scripts/azure-run-base-tests.sh +++ b/ipatests/azure/scripts/azure-run-base-tests.sh @@ -14,6 +14,7 @@ function collect_logs() { printf "Collecting logs\n" journalctl -b --no-pager > systemd_journal.log tar --ignore-failed-read -czf "$out_file" \ + --warning=no-failed-read \ /var/log/dirsrv \ "$HTTPD_LOGDIR" \ /var/log/ipa* \ diff --git a/ipatests/azure/templates/test-jobs.yml b/ipatests/azure/templates/test-jobs.yml index 16b225cb6..e0e25c633 100644 --- a/ipatests/azure/templates/test-jobs.yml +++ b/ipatests/azure/templates/test-jobs.yml @@ -93,7 +93,7 @@ steps: printf "SECCOMP:\n" grep ' SECCOMP ' "$HOST_JOURNAL" && \ emit_warning "There are reported SECCOMP syscalls. Please, check the logs." - tar --ignore-failed-read -czf "$HOST_JOURNAL_PATH" "$HOST_JOURNAL" + tar -czf "$HOST_JOURNAL_PATH" "$HOST_JOURNAL" condition: succeededOrFailed() displayName: Host's systemd journal diff --git a/ipatests/pytest_ipa/integration/__init__.py b/ipatests/pytest_ipa/integration/__init__.py index c25bcd848..b6c5ca924 100644 --- a/ipatests/pytest_ipa/integration/__init__.py +++ b/ipatests/pytest_ipa/integration/__init__.py @@ -218,9 +218,17 @@ def collect_logs(name, logs_dict, logfile_dir=None, beakerlib_plugin=None): tmpname = cmd.stdout_text.strip() # Tar up the logs on the remote server cmd = host.run_command( - ['tar', 'cJvf', tmpname, '--ignore-failed-read', - '--dereference'] + logs, - log_stdout=False, raiseonerr=False) + [ + "tar", + "cJvf", + tmpname, + "--ignore-failed-read", + "--warning=no-failed-read", + "--dereference", + ] + logs, + log_stdout=False, + raiseonerr=False, + ) if cmd.returncode: logger.warning('Could not collect all requested logs') # fetch tar file