Wrangling Gerrit accounts

Or, how I learned to stop worrying and love duplicate accounts.

Posted by Ian Maxon on April 18, 2015

If you run a Gerrit instance with OpenID, you are probably also have the issue of folks with duplicate accounts. Gerrit doesn't indicate clearly to users when it is going to create an account versus logging into an extant one, so it's not exactly surprising. It can become extra fun when two OpenID accounts end up having the same (name,email) combination- which can stop that user from being possible to add to reviews. The first question that comes to mind with this is typically something like "how the heck do I get rid of all of these errant accounts!?". Looking around it isn't hard to find all sorts of solutions to this issue, most of which involve editing the Gerrit database directly- which I really don't care for. It is quite easy to get into a situation where changes can become orphaned.

The way I have come to solve this problem is simple. Gerrit does allow accounts to be marked as inactive. This might sound not exactly similar. However the effect of marking an account active is closer to deleting it than anything. The only difference being, whatever OpenID credential was tied to it, can't be tied to another account. That too might sound like an issue, but the user just has to pick one ID- set account allows the key and so on to be cleared out as well.

This also handles the case where an account is created instead of being linked on accident. Presumably the user is attempting to use that ID as a primary login, so it's just a matter of moving the keys to the accidentally created account, and marking the old one as inactive. Hopefully Gerrit will extend set-account soon enough to allow movement of OpenID credentials between accounts. Until then however, set-account is a viable alternative to scary database alterations.