Closed Bug 805874 Opened 14 years ago Closed 2 years ago

Mercurial hook to automatically add changeset URL comments to bugs when they land and are merged

Categories

(Developer Services :: Mercurial: hg.mozilla.org, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: snorp, Unassigned)

References

Details

(Whiteboard: [kanban:engops:https://mozilla.kanbanize.com/ctrl_board/6/718] )

Typically, people post the url to the hg changeset whenever they push a patch for a bug. While it is nice that the server includes the url for easy copy/pasting, it would be even nicer if it just did it all for me. It should be relatively easy to figure out the bug # given the standard commit message format of "Bug 12345 - Do stuff", and of course we already know the url to post.
The hook that prints the URLs is: http://hg.mozilla.org/hgcustom/hghooks/file/81840580bc95/mozhghooks/push_printurls.py The tricky bit here is that this requires something with write access to Bugzilla, and I'm not sure how happy Server Ops would be with that.
Dupe of bug 799101?
(In reply to Ted Mielczarek [:ted.mielczarek] from comment #1) > The hook that prints the URLs is: > http://hg.mozilla.org/hgcustom/hghooks/file/81840580bc95/mozhghooks/ > push_printurls.py > > The tricky bit here is that this requires something with write access to > Bugzilla, and I'm not sure how happy Server Ops would be with that. Not really happy, we need opsec clarification/review of this if that's the case.
(In reply to Shyam Mani [:fox2mike] from comment #3) > > The tricky bit here is that this requires something with write access to > > Bugzilla, and I'm not sure how happy Server Ops would be with that. > > Not really happy, we need opsec clarification/review of this if that's the > case. This could be implemented fairly easily with a non-privileged bugzilla account & bzapi calls from within the pushlog hook (we'd only comment on public bugs). Apart from this being from a hook, we already do similar for TBPL's bug starring, so I don't see how this would be problematic from a security POV.
(In reply to Ed Morley [:edmorley UTC+0] from comment #4) > This could be implemented fairly easily with a non-privileged bugzilla > account & bzapi calls from within the pushlog hook (we'd only comment on > public bugs). Apart from this being from a hook, we already do similar for > TBPL's bug starring, so I don't see how this would be problematic from a > security POV. Was the tbpl bit approved by opsec? I am concerned about adding additional steps to puhlog, we have enough issues with hg already. We should make sure this doesn't impact pushes (say if Bugzilla is down or unreachable for example).
(In reply to Shyam Mani [:fox2mike] from comment #6) > Was the tbpl bit approved by opsec? I'm not sure to which part you are referring, so I'll answer both alternatives. TBPL doesn't use a mercurial hook, bzapi is triggered when people star failed builds on tbpl.mozilla.org. TBPL's security review was bug 661365; bzapi is public & anyone can create an unprivileged b.m.o account, so any potential sanitisation of data has to occur on the bzapi end anyway. > I am concerned about adding additional > steps to puhlog, we have enough issues with hg already. We should make sure > this doesn't impact pushes (say if Bugzilla is down or unreachable for > example). Agreed; whomever implements this would obviously use a timeout.
10:24:32 - AryehGregor: So no one's written a bot yet that posts the changeset links to the bug? 10:24:45 - AryehGregor: That would remove the one manual step other than pushing. 10:25:22 - AryehGregor: (which is actually sometimes mildly annoying if you have a bunch of changesets pushed all at once)
OS: Mac OS X → All
Hardware: x86 → All
(Struggled to find this by searching - making summary more keyword-rich)
Summary: Server hook to automatically post hg urls → Mercurial hook to automatically add changeset URL comments to bugs when they land and are merged
Having implemented a similar hook at another company, push hooks should be very sensitive to interactions with 3rd party systems. In this case, having the push hook query Bugzilla or bzapi creates an operational dependency between Mercurial and Bugzilla. Consider: * What happens if Bugzilla/bzapi is completely down? * What happens if Bugzilla/bzapi is responding slowly? * What happens if the push contains many (hundreds) of bug references? A naive hook may not implement timeouts (causing pushes to never finish). A less naive hook may implement timeouts. But pushers are still inconvenienced by the push waiting for the hook to finish. An even less naive hook may create a new daemon process to perform all the post-processing. But, if 3rd party services are misbehaving, this could result in dozens of processes on the Mercurial server, causing high load and resource utilization. Unless the action the push hook is taking is mandatory, a robust hooks system utilizes a queue for post-processing. When I implemented something similar like 5 years ago, we used email as the queue. We delivered machine-readable emails to an SMTP server on the version control server (the local SMTP server was guaranteed to always be running so if we couldn't deliver locally, the push was rejected). We had some other machine slurping off the emails and doing the heavy lifting. If the action couldn't be completed, we simply left the email in the inbox and tried again. If it failed N times, the commit author was notified via email. If I were designing this today, I'd probably use a real queue system. I don't know if IT has anything available that would be easily usable. If not, email might still be the path of least resistance. No matter what is used, it's important to consider what happens when 3rd party services are misbehaving. Since that inevitably involves "async" processing of hooks, you also need to solve the problem of data persistence and retries. I wish this problem were simpler.
Another option would be to get bug 603037 rolled out onto bmo...
(In reply to Reed Loden [:reed] from comment #11) > Another option would be to get bug 603037 rolled out onto bmo... In addition to, I think. That project's hook.pl uses synchronous HTTP requests to update Bugzilla: you still have the problem of Mercurial relying on the operational characteristics of Bugzilla. I think this will break down for large pushes (like merge commits).
Gregory, Thanks for adding those completely valid points. I couldn't have articulated them any better in this case :) We already have a lot of single points of failure in the entire commit <-> build chain and I'm not a fan of adding another to that.
would it be viable to have a separate system which monitors the hg log and updates bugzilla where appropriate? updates to bugzilla wouldn't be immediate, and polling isn't ideal, however it would be fault tolerant, and wouldn't add anything into the critical path.
That's probably doable, and probably the best way to architect this.
Product: mozilla.org → Release Engineering
Product: Release Engineering → Developer Services
Whiteboard: [kanban:engops:https://kanbanize.com/ctrl_board/6/192]
Whiteboard: [kanban:engops:https://kanbanize.com/ctrl_board/6/192] → [kanban:engops:https://mozilla.kanbanize.com/ctrl_board/6/718] [kanban:engops:https://kanbanize.com/ctrl_board/6/192]
Whiteboard: [kanban:engops:https://mozilla.kanbanize.com/ctrl_board/6/718] [kanban:engops:https://kanbanize.com/ctrl_board/6/192] → [kanban:engops:https://mozilla.kanbanize.com/ctrl_board/6/718]
This is accomplished by Pulsebot today. But I'm keeping this bug open because we'll have a better way to do this on the server once the new replication is in place.
QA Contact: hwine
QA Contact: hwine → klibby

pulsebot has been doing this for the past many years, I doubt that'll change in the foreseeable future.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.