Python Version Check for Taskotron
ClosedPublic

Authored by churchyard on Jul 22 2016, 8:27 AM.

Details

Reviewers
kparal
jskladan
Group Reviewers
libtaskotron
Summary

This is a check that makes sure packages do not require both Pythons (2 & 3), except explicitly listed packages. It is a common mistake when porting stuff to Python 3, that shebangs leave the dependency on Python 2 as well etc.

Test Plan
$ runtask -i tracer-0.6.9-1.fc23 -t koji_build runtask.yaml
...
[python-versions] 11:22:17 ERROR   tracer-0.6.9-1.fc23.noarch.rpm requires both Python 2 and 3, that's usually bad.
[python-versions] 11:22:17 INFO    python-versions FAILED for tracer-0.6.9-1.fc23 (tracer-0.6.9-1.fc23.noarch.rpm requires Python 2 and 3)
[libtaskotron] 11:22:17 INFO    Reporting to ResultsDB is disabled. Once enabled, the following would get reported:
results:
- artifact: /var/lib/taskotron/artifacts/20160920_112213_239750/output.log
  item: tracer-0.6.9-1.fc23
  note: tracer-0.6.9-1.fc23.noarch.rpm requires Python 2 and 3
  outcome: FAILED
  type: koji_build

$ runtask -i eric-6.1.6-2.fc25 -t koji_build runtask.yaml
...
[python-versions] 11:22:56 WARNING eric is excluded from this check
[python-versions] 11:22:56 INFO    python-versions PASSED for eric-6.1.6-2.fc25 (no problems found)
[libtaskotron] 11:22:56 INFO    Reporting to ResultsDB is disabled. Once enabled, the following would get reported:
results:
- item: eric-6.1.6-2.fc25
  note: no problems found
  outcome: PASSED
  type: koji_build

$ runtask -i python-six-1.10.0-3.fc25 -t koji_build runtask.yaml
...
[python-versions] 11:23:23 INFO    python-six-1.10.0-3.fc25.noarch.rpm requires Python 2 only, that's OK
[python-versions] 11:23:23 INFO    python3-six-1.10.0-3.fc25.noarch.rpm requires Python 3 only, that's OK
[python-versions] 11:23:23 INFO    python-versions PASSED for python-six-1.10.0-3.fc25 (no problems found)
[libtaskotron] 11:23:23 INFO    Reporting to ResultsDB is disabled. Once enabled, the following would get reported:
results:
- item: python-six-1.10.0-3.fc25
  note: no problems found
  outcome: PASSED
  type: koji_build

$ runtask -i python3-3.5.1-17.fc24 -t koji_build runtask.yaml
...
[python-versions] 11:40:12 INFO    python3-3.5.1-17.fc24.armv7hl.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-3.5.1-17.fc24.i686.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-3.5.1-17.fc24.x86_64.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-debug-3.5.1-17.fc24.armv7hl.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-debug-3.5.1-17.fc24.i686.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-debug-3.5.1-17.fc24.x86_64.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-devel-3.5.1-17.fc24.armv7hl.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-devel-3.5.1-17.fc24.i686.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-devel-3.5.1-17.fc24.x86_64.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-libs-3.5.1-17.fc24.armv7hl.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-libs-3.5.1-17.fc24.i686.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-libs-3.5.1-17.fc24.x86_64.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-test-3.5.1-17.fc24.armv7hl.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-test-3.5.1-17.fc24.i686.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-test-3.5.1-17.fc24.x86_64.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-tkinter-3.5.1-17.fc24.armv7hl.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-tkinter-3.5.1-17.fc24.i686.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-tkinter-3.5.1-17.fc24.x86_64.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-tools-3.5.1-17.fc24.armv7hl.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-tools-3.5.1-17.fc24.i686.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python3-tools-3.5.1-17.fc24.x86_64.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    system-python-3.5.1-17.fc24.armv7hl.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    system-python-3.5.1-17.fc24.i686.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    system-python-3.5.1-17.fc24.x86_64.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    system-python-libs-3.5.1-17.fc24.armv7hl.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    system-python-libs-3.5.1-17.fc24.i686.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    system-python-libs-3.5.1-17.fc24.x86_64.rpm requires Python 3 only, that's OK
[python-versions] 11:40:12 INFO    python-versions PASSED for python3-3.5.1-17.fc24 (no problems found)
[libtaskotron] 11:40:12 INFO    Reporting to ResultsDB is disabled. Once enabled, the following would get reported:
results:
- item: python3-3.5.1-17.fc24
  note: no problems found
  outcome: PASSED
  type: koji_build

$ runtask -i python-admesh-0.98.5-3.fc25 -t koji_build runtask.yaml
...
warning: /var/cache/taskotron/python-admesh-0.98.5-3.fc25.aarch64.rpm: Header V3 RSA/SHA1 Signature, key ID e372e838: NOKEY
[python-versions] 11:53:12 ERROR   python-admesh-0.98.5-3.fc25.aarch64.rpm: public key not available
[python-versions] 11:53:12 INFO    python-admesh-0.98.5-3.fc25.armv7hl.rpm requires Python 2 only, that's OK
[python-versions] 11:53:12 INFO    python-admesh-0.98.5-3.fc25.i686.rpm requires Python 2 only, that's OK
[python-versions] 11:53:12 INFO    python-admesh-0.98.5-3.fc25.x86_64.rpm requires Python 2 only, that's OK
[python-versions] 11:53:12 ERROR   python3-admesh-0.98.5-3.fc25.aarch64.rpm: public key not available
[python-versions] 11:53:12 INFO    python3-admesh-0.98.5-3.fc25.armv7hl.rpm requires Python 3 only, that's OK
[python-versions] 11:53:12 INFO    python3-admesh-0.98.5-3.fc25.i686.rpm requires Python 3 only, that's OK
[python-versions] 11:53:12 INFO    python3-admesh-0.98.5-3.fc25.x86_64.rpm requires Python 3 only, that's OK
[python-versions] 11:53:12 INFO    python-versions PASSED for python-admesh-0.98.5-3.fc25 (no problems found)
[libtaskotron] 11:53:12 INFO    Reporting to ResultsDB is disabled. Once enabled, the following would get reported:
results:
- item: python-admesh-0.98.5-3.fc25
  note: no problems found
  outcome: PASSED
  type: koji_build

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
churchyard retitled this revision from to Python Version Check for Taskotron.Jul 22 2016, 8:27 AM
churchyard updated this object.
churchyard edited the test plan for this revision. (Show Details)
churchyard added inline comments.Jul 22 2016, 8:51 AM
python_versions_check.py
134

What shall be here instead of TODO?

Just a note: into "Test plan" you put what you've done to test that this DR works (and we should be able to repeat this test to verify it).

churchyard edited the test plan for this revision. (Show Details)Jul 22 2016, 10:37 AM
jskladan accepted this revision.Jul 26 2016, 12:31 PM
jskladan added a reviewer: jskladan.
jskladan added a subscriber: jskladan.

Looks good to me, apart of the comment below.
Sorry for the late reply - we're preparing for Flock, so the response rate is a bit low now...

python_versions_check.py
132–134

This is probably not well documented, but the note should be something quite short. I suggest creating a file containing the suggestion, and adding it as an artifact to the result. Something in the likes of:

if bads:
    s = 's' if len(bads) else ''
    detail.artifact = os.path.join(workdir, 'output.log'
    with open(detail.artifact, 'w') as output:
        output.write ('{} require{} both Pythons, '
	                       'if you think that\'s false or intentional, '
	                       'file a bug against TODO'.format(','.join(bads), s))
This revision is now accepted and ready to land.Jul 26 2016, 12:31 PM
kparal requested changes to this revision.Aug 3 2016, 2:52 PM
kparal added a reviewer: kparal.
kparal added a subscriber: kparal.

The script looks good. Please create an artifact instead of using note and better explain the packagers what's wrong with their packages in case of a failure, and I think we can soon push this to our dev instance.

python_versions_check.py
132–134

This is not completely correct. The result file (txt, html, whatever you want) needs to be created in artifacts directory, not workdir. You can pass ${artifactsdir} variable from the task formula to the python script so that you know where to create it.

But overall, yes, the note is optional and supposed to contain something short and useful (e.g. 1 fail, 49 passes) when manually reviewing the results in ResultsDB. It's not a good fit here. You can either print the errors to stdout and hope that people reading the logs will see it, or (more user friendly) create a specific file where you explain what went wrong, print helpful details, link some FAQ or project page for this check (so that people can report bugs or request whitelisting), etc.

The advantage of this is that you can be really verbose and explain what's wrong, since these reports will be likely read by many packagers who will have no idea what this check is for. Currently {} require{} both Pythons doesn't really explain what's wrong (and "both Pythons" in itself is very ambiguous).

runtask.yaml
4

This could be a bit more specific (what can go wrong with the dependencies?). We have no limit on description length.

This revision now requires changes to proceed.Aug 3 2016, 2:52 PM
churchyard updated this revision to Diff 2572.Sep 20 2016, 11:58 AM
churchyard edited the test plan for this revision. (Show Details)
  • In case of failure, create a log with more descriptive message
  • The note is less verbose
  • Log the filename, not the path
  • More verbose description
  • Add a list of packages not indicating a dependency (python-(s)rpm-macros)
  • Do not traceback when something goes bad with RPM
  • PEP 8 stuff
kparal accepted this revision.Oct 12 2016, 1:47 PM

Apart of that small nitpick, I don't see any problem with this.

Now you'll need to set up a git repo with this check somewhere and give us the URL. Set up at least two branches - develop and master. develop is going to be used at our dev and stg instance, and master is going to be used at our production instance. Both branches will be automatically pulled every hour.

python_versions_check.py
162–164

Listing all rpm file names in note can make it possibly very long. I'd say this is much more appropriate to put into the log file (where it already is). Are affected RPM filenames something that the maintainer should immediately see from the resultsdb interface, before clicking to see the log file? Is that going to be mostly useful?

I'd recommend removing the note completely, because I see no good usage for it in this particular check. However, that's just a recommendation. We'll need get used to field values which do not satisfy our aesthetic goals, or start restricting them (e.g. in length) somehow sooner or later :)

This revision is now accepted and ready to land.Oct 12 2016, 1:47 PM

I created T860 to deploy this task. You can close the review now, thanks.

churchyard closed this revision.Oct 21 2016, 12:15 PM