openSUSE / obs-service-go_modules

OBS Source Service to download, verify, and vendor Go module dependency sources
GNU General Public License v2.0
19 stars 18 forks source link

subprocess call silently fails due to Python version incompatibility #22

Closed stefanotorresi closed 1 year ago

stefanotorresi commented 2 years ago

using the command osc service runall on a package with the source service unexpectedly started to silently fail with the following error:

INFO:obs-service-go_modules:go mod download
Traceback (most recent call last):
  File "/usr/lib/obs/service/go_modules", line 276, in <module>
    main()
  File "/usr/lib/obs/service/go_modules", line 229, in main
    cp = cmd_go_mod("download", go_mod_dir)
  File "/usr/lib/obs/service/go_modules", line 183, in cmd_go_mod
    cp = run(["go", "mod", cmd], cwd=dir, capture_output=True, text=True)
  File "/usr/lib64/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'capture_output'

You can observe the real world scenario by opening this GH action job https://github.com/trento-project/agent/actions/runs/3137152974/jobs/5094982098 and expanding the commit changes into OBS step.

The error appears to happen due to the capture_output argument being only available since Python 3.7, while the spec file of this package does not have this requirement explicitly set. Running the osc and source service in a opensuse/leap:15.4 container image like this one means the version of Python that gets installed will be 3.6.

A most impacting aspect is actually that osc exits with 0 despite the source failing, which meant we couldn't detect the issue when the change was introduced four months ago!

alexandrevicenzi commented 1 year ago

I encountered the same issue on Leap 15.3, currently, it is possible to install the latest version from devel:go repositories since devel:go still has 15.3.

I think the go-modules lib should still support Python 3.6, or explicitly request for a newer Python.

jfkw commented 1 year ago

This is fixed in PR #15 . There are now code paths for the subprocess.run() API when Python >= 3.7 and another for earlier versions.

We will look for recurrences of Issue #20 with Python < 3.7 and revisit that code path if additions to stdout capture and error handling is needed.