Script that posts Gerrit patch URL to Launchpad bugs not working

Bug #1455993 reported by Aaron Wells
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Aaron Wells

Bug Description

It appears that the script that posts Gerrit patch URLs onto Launchpad bugs may be broken at the moment. This is probably related to the Gerrit upgrade that we carried out last week.

Revision history for this message
Aaron Wells (u-aaronw) wrote :
Download full text (4.2 KiB)

Messages in the error logs. Looks like the problem is due to Python. Probably we're either missing a python library on the new server, or it's a version compatibility issue (the old server had Python 2.6 and the new server has Python 2.7).

[2015-05-18 07:09:27,284] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] exitValue:1
[2015-05-18 07:09:27,284] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: Traceback (most recent call last):
[2015-05-18 07:09:27,285] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: File "/home/gerrit/mahara-scripts/patchset-created", line 122, in <module>
[2015-05-18 07:09:27,285] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: sys.exit(main())
[2015-05-18 07:09:27,285] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: File "/home/gerrit/mahara-scripts/patchset-created", line 78, in main
[2015-05-18 07:09:27,285] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: args, unused = getopt(sys.argv[1:], '', gerrit_args)
[2015-05-18 07:09:27,285] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: File "/usr/lib/python2.7/getopt.py", line 88, in getopt
[2015-05-18 07:09:27,285] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: opts, args = do_longs(opts, args[0][2:], longopts, args[1:])
[2015-05-18 07:09:27,285] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: File "/usr/lib/python2.7/getopt.py", line 152, in do_longs
[2015-05-18 07:09:27,285] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: has_arg, opt = long_has_args(opt, longopts)
[2015-05-18 07:09:27,285] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: File "/usr/lib/python2.7/getopt.py", line 169, in long_has_args
[2015-05-18 07:09:27,285] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: raise GetoptError('option --%s not recognized' % opt, opt)
[2015-05-18 07:09:27,285] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: getopt.GetoptError: option --kind not recognized

[2015-05-18 09:05:10,905] INFO com.google.gerrit.common.ChangeHookRunner : hook[change-merged] exitValue:1
[2015-05-18 09:05:10,905] INFO com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output: Traceback (most recent call last):
[2015-05-18 09:05:10,906] INFO com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output: File "/home/gerrit/mahara-scripts/change-merged", line 187, in <module>
[2015-05-18 09:05:10,906] INFO com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output: sys.exit(main())
[2015-05-18 09:05:10,906] INFO com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output: File "/home/gerrit/mahara-scripts/change-merged", line 163, in main
[2015-05-18 09:05:10,906] INFO com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output: args, unused = getopt(sys.argv[1:], '', gerrit_args)
[2015...

Read more...

Revision history for this message
Aaron Wells (u-aaronw) wrote :

Turns out the problem was that Gerrit added a couple of command-line arguments that it sends to the hook scripts. And the python getopt() method that I'm using, crashes if it receives unrecognized arguments.

So even though we're not using those new arguments, the fix is to add them to the list of recognized arguments.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/4769/

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "master" branch: https://reviews.mahara.org/4772

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/4772
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/d726cccd6877f7225e381df8cbfe3ce4ffa35623
Submitter: Aaron Wells (<email address hidden>)
Branch: master

commit d726cccd6877f7225e381df8cbfe3ce4ffa35623
Author: Aaron Wells <email address hidden>
Date: Mon May 18 15:49:22 2015 +1200

Revert "Bug 1455993: Testing Gerrit/Launchpad integration hooks"

This reverts commit dafb6b258280c59f8e105e4a041569e594417361.

Change-Id: I5582ec612c0b9d63375ac915fa89e7e9c1c7f03a

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/4773

Revision history for this message
Aaron Wells (u-aaronw) wrote :

Okay, got the scripts working again.

In addition to adding those new arguments I ran into a couple of hiccups:

1. I refactored the mahara-scripts repository so that the gerrit hook scripts are now in a subdirectory called "gerrit". I updated Gerrit's symlinks to point to the new location, but Gerrit still refused to actually call the new scripts until I restarted it.

2. The Gerrit 2.11 manual is missing one argument that gets passed to change-merged: "--newrev <new rev>". So I had to add that as well. I've filed a bug with Gerrit asking them to update their documentation: https://code.google.com/p/gerrit/issues/detail?id=3374&thanks=3374&ts=1431921610

Marking this one "Finished" now. :)

Changed in mahara:
status: In Progress → Fix Released
Revision history for this message
Aaron Wells (u-aaronw) wrote :

Oh yeah, and the commit and merge messages listed above, are not actually the changes that fix this problem. ;) Those are test messages from a patch that I filed and merged in order to trigger the scripts.

The changes that fixed this problem, well, I didn't actually run them through Gerrit, although I could have because we're now tracking mahara-scripts in Gerrit. The changes are these:

https://github.com/MaharaProject/mahara-scripts/commit/8d305e6d36ec0fdf44eede9cf7e440acf73110ba
https://github.com/MaharaProject/mahara-scripts/commit/1946aa7304a39a4d4f0f3f11bc0ef9c4213a71df
https://github.com/MaharaProject/mahara-scripts/commit/3e93cc5ac9dbfcca8da6906bf2527ce90793449e
https://github.com/MaharaProject/mahara-scripts/commit/4a0c79462d1d95a4f73c654f1fffaea36fd01dcc

tags: added: gerrit launchpad reviews.mahara.org
tags: added: mahara-scripts
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.