818830b25e
This commit fixes various minor issues in utils.py Python module's run_shell_cmd function: - Fix "local variable 'process' referenced before assignment" exception that can occur while handling exceptions raised by subprocess.Popen(). This appears to only occur when a forked/child process cannot execute a program, which is a programming error, which in turn is a minor issue. Before this commit, attempting to run a non-existent program with, for example: 'run_shell_command("/bin/abc", ...)' would result in the exception "local variable 'process' referenced before assignment" while handling the exception "[Errno 2] No such file or directory: '/bin/abc'". With this commit, only the latter exception is reported, but in the following form, as part of a single/non-nested exception: [ Failed to execute command: "['/bin/abc']" Exception: "[Errno 2] \ No such file or directory: '/bin/abc'" ] - Avoid making Python print two tracebacks when handling exceptions raised by subprocess.Popen(). Logging a one-line description of the exception encountered by subprocess.Popen() (via "{e}", where "e" is an Exception object) is sufficient on its own to debug the encountered issue. (Please see above for an example.) - Always log standard error of the command. While most of the messages logged to the standard error are debugging-oriented or point at minor issues, ignoring standard error still causes us to miss non-critical warning messages. In addition, change the log level for standard error output from "error" to "debug" to avoid panicking build system users due to the non-critical messages that will appear, such as the following: dpkg-architecture: warning: cannot determine CC system type, falling \ back to default (native compilation) dpkg-source --before-build . dpkg-buildpackage: warning: building a source package without \ cleaning up as you asked; it might contain undesired files dpkg-source -b . dpkg-genbuildinfo --build=source dpkg-genchanges --build=source >../mlnx-ofed-kernel_....changes dpkg-genchanges: info: not including original source code in upload - In the logs, prefix the command's standard output with "stdout: " and its standard error with "stderr: ". This allows distinguishing between the command's messages emitted via standard output and standard error. - Note that adding the "stdout: " prefix to each line of each command's standard output increases the log file's size by about 190 KiB, according to the following results from a fresh build with 'build-pkgs -b std,rt -c -a': $ grep -e '2022-09-1[67] .*stdout: ' builder.log | wc -l 24391 # num_lines $ echo $(( 24391 * 8 )) # i.e., num_lines * strlen("stdout: ") 195128 # bytes Logging each command's standard error (along with prefixing each line with "stderr: ") adds about 1.87 MiB of output to the build logs, which corresponds to an increase of approximately 21 percent: $ grep -e '2022-09-1[67] .*stderr: ' builder.log | wc -c 1963024 $ grep -e '2022-09-1[67] ' builder.log | wc -c 11164207 $ echo 'scale=2; print 1963024.0/(11164207-1963024) * 100,"%\n";' \ | bc 21.00% Despite the increase in the log file size, logging the standard error uncovers some issues, mostly relating to the debian/changelog file formatting used by StarlingX developers, which are admittedly minor. Examples include: ... stderr: dpkg-genchanges: warning: debian/changelog(l...): \ badly formatted trailer line ... stderr: dpkg-genchanges: warning: debian/changelog(l...): \ found end of file where expected more change data or trailer - Log the return code of the command if it fails. This provides additional information regarding why a command failed, in case the command's output is not sufficient to determine the reason. - Prefer to log the command as a list/tuple if it is provided with that type, for easier correlation with the code and for consistency with the rest of the logging in the function. - Improve logging and reduce the duplication involved in log message construction. Verification - 'build-pkgs -b rt,std -c -a' runs without issues with this patch, but emits additional output due to logging the standard error streams of executed commands. Closes-Bug: 1989009 Closes-Bug: 1990177 Change-Id: I6b3c4dc70fb1404280ea15e8dcc573c83792f9b1 Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com> |
||
---|---|---|
.. | ||
branching | ||
build_guest | ||
build_iso | ||
build_minimal_iso | ||
build-docker-images | ||
build-wheels | ||
certificates | ||
deb-utils | ||
mk | ||
repo_files | ||
requirements | ||
signing | ||
stx | ||
unit-tests | ||
audit-pkgs | ||
build-avoidance-utils.sh | ||
build-guest | ||
build-helm-charts.sh | ||
build-img | ||
build-iso | ||
build-pkg-srpm | ||
build-pkgs | ||
build-pkgs-parallel | ||
build-pkgs-serial | ||
build-remote-cli.sh | ||
build-rpms | ||
build-rpms-parallel | ||
build-rpms-serial | ||
build-srpms | ||
build-srpms-common.sh | ||
build-srpms-parallel | ||
build-srpms-serial | ||
Cached_Data.txt | ||
classify | ||
create_dependancy_cache.py | ||
create-yum-conf | ||
deb-utils.sh | ||
default_build_srpm | ||
find_klm | ||
find_patched_srpms_needing_upgrade | ||
git-repo-utils.sh | ||
git-utils.sh | ||
helm_chart_modify.py | ||
image-utils.sh | ||
ip_report.py | ||
make-installer-images.sh | ||
mock_cfg_to_yum_conf.py | ||
mockchain-parallel | ||
mockchain-parallel-1.3.4 | ||
mockchain-parallel-1.4.16 | ||
mockchain-parallel-2.6 | ||
mockchain-parallel-2.7 | ||
modify-build-cfg | ||
patch_rebase_1 | ||
patch_rebase_2 | ||
patch_rebase_3 | ||
patch_rebase_4 | ||
patch-iso | ||
pkg-manager-utils.sh | ||
repo-utils.sh | ||
sign_iso_formal.sh | ||
sign_patch_formal.sh | ||
sign-rpms | ||
sign-secure-boot | ||
source_lookup.txt | ||
spec-utils | ||
srpm-utils | ||
stxRpmUtils.py | ||
sync_jenkins.sh | ||
sync-jenkins | ||
tis.macros | ||
update-efiboot-image | ||
update-pxe-network-installer | ||
url_utils.sh | ||
utils.sh | ||
wheel-utils.sh | ||
wrs_orig.txt | ||
yum-builddep-wrapper |