Gerrit Hackathon at Google HQ… next one is coming

Gerrit Hackathon 2015Gerrit Hackathon 2015

As always after the Gerrit User Summit, a Gerrit hackathon took place.
This time it was a five days event (9-11 November 2015), where members of the Gerrit community could work together, fully focused on making Gerrit a better software.
2015 edition gathered 15 participants from various companies like Google, SAP, Sony Mobile, Qualcomm, OpenStack, Axis Communications, Gerritforge and of course CollabNet.
Hackathons are really intensive periods of time for Gerrit project: over 400 patches were merged, three releases (2.11.5 and two release candidates of 2.12) were performed, countless number of open changes and patchsets were pushed for review.
This blog post summarizes work done during that period of time, showcasing new features upcomming in 2.13 and 3.0 release.

Gerrit metrics

Gerrit Metrics in Grafana2Gerrit Metrics in Grafana2

If you are responsible for running mission critical software for your organization, you must know how important monitoring and metrics are. How important it is to get fine grained information about the application performance. It is simply not enough to know whether it is up and running but also what is the overall shape of it.
This kind of information is especially critical when users start complaining “Gerrit is slow”.
From time to time such complaints arrive also to our team in Potsdam, then we use Splunk to analyze the load based on Gerrit logs and give our recommendations how to tweak Gerrit. Based on such cases our Gerrit Performance Cheatsheet was composed meuh7iu.
Starting from Gerrit 2.13 we will have a new tool in our toolbox! Internal Gerrit metrics!
DropWizard Metrics library is used as internal engine. Gerrit exposes over 1300 metrics about crucial internals e.g. http server response time, git receive pack, git counting objects, cache sizes, etc….
What is even more awesome, plugins can report their own metrics using the core API. This way replication plugin for 2.13 will report time taken to replicate repository data to various locations.
One thing is to collect metrics, the other is to store them. For this purpose three new plugins were created: metrics-reporter-elasticsearch, metrics-reporter-graphite and metrics-reporter-jmx. This gives possibility to plug Gerrit in into already existing infrastructure.

Hooks as plugins for core events

There are two ways in Gerrit how one can be notified about git operation related events. One is via event mechanism and another via Gerrit hooks. Both provide almost identical functionality making deciding on implementing one of them harder.

During our hackathon work was started to extract hooks mechanism into plugins that would listen to core Gerrit events.

This work is still ongoing, but once it gets finished one that want to run server side hooks must install the Gerrit hook plugin.

gwtorm can be used from plugins

You may be wondering what is the gwtorm. This is a library written for Gerrit project to access relational databases. It is a lightweight method of connecting your Java application to multiple different DB backends. Initially it was meant to be used only by GWT based applications (hence gwt prefix in its name), but currently it can be used by any Java application.

Why to use gwtorm in plugin? Well if you don’t want to modify Gerrit schema (which is highly discouraged) to store your plugin data and want to support many SQL dialects out of the box, gwtorm is the way to go.

The first plugin that will use this library is gerrit-ci-plugin.

Gerrit 2.11.5 and 2.12-rc

Gerrit releases don’t happen too often. Some time we had to wait long months (and over 1000 commits) to get new stable version of Gerrit. Usually just before the hackathon a release candidate of new stable version is cut from the master branch.

During this year’s hackathon we got three releases! One was a service release for 2.11 (updated release notes) branch containing fixes for javascript clipboard, styling, commit validation error handling.

Apart from service release two release candidates were published for Gerrit 2.12.

Submit whole topic dialog

Gerrit 2.12 changes how patches are submitted to the repository after code review. In all previous versions there was so called “merge queue” which was responsible for submitting patches in the right order. If particular change was submitted but its ancestors were still under review it ended up in a special state “submitted, merge pending”.

In 2.12 changes arranged in a branch (one change depending on the other) can be submitted at once by single click on the submit button on the topmost change.

Additionally new feature called ‘submit whole topic’ was added. It enables submission of changes that share the same topic. This can be done across multiple projects and branches.

One thing that struck us when this feature was presented during Gerrit User Summit was change in the semantic of Gerrit ‘topic’. Before 2.12 topics were only metadata that could have been freely added and removed. Plus there was possibility to search for changes that share the same topic. Starting from  2.12 setting a topic on changes will change how they are submitted. In some rare cases one can submit changes of others or block them because of a change not visible to all is still waiting for being reviewed.

To make submitting more verbose during the transition period, a submit dialog was proposed. It pops up after clicking on the submit button only when changes from the same topic would be submitted. It presents the list of changes submitted in a topic and without it, so that the submitter can choose whether to just merge the change in question or all changes of the same topic.

CI verification

Some time ago a Diffy build bot was introduced to verify changes pushed to gerrit-review.googlesource.com, but after some time it become unreliable, often was simply not verifying because it was not running.
Now there is new verifier in the picture. Based on proven gerrit-trigger-plugin custom REST API pooling strategy and Jenkins tandem. It is kindly hosted by the GerritForge. Long life to new GerritForge CI bot!

NoteDB

NoteDB is the defining feature of Gerrit 3.0. It will replace “conventional” database system and store everything inside git repositories. All the data that is currently stored in SQL DB will be moved to git repositories. Review related information will be stored in the particular repository using git-notes and special refs. User data will be moved to dedicated repository.
During the hackathon further steps into achieving the goal of removing the dependency from SQL DB were performed, some integration tests were fixed plus NoteDB tests were enabled  as a part of verification job.

New Gerrit UI with Polymer

Last but not least, the new Polymer based WEB UI for Gerrit was initially announced and integrated into Gerrit’s build process.

During the Gerrit User Summit, Google has presented the draft of a new Gerrit WEB UI. This time it is written using Polymer framework, which is a new JavaScript UI design framework from Google.

The new WEB UI will be fully written in JavaScript, making it easier for UI/UX designers to modify and faster to develop and compile.

As I mentioned before, during hackathon PolyGerrit project was integrated into standard Gerrit build system. It requires teaching Buck how to deal with javascript and its dependencies.

What is next?

Next is the Berlin Gerrit Hackathon in 2016. We’ve open a poll to gather input from the community about preferable date between 22nd of February and 25th of March 2016. Please participate if you would like to join us and hack Gerrit in Berlin 🙂

How to easy customize Gerrit Submit rules

Gerrit submit rule is a set of conditions that needs to be fulfilled before change can be submitter (read merged) to given branch. By default there are only two simple conditions:

  1. Verified +1 (V+1)
  2. Code Review +2 (CR+2)

First one means that change don’t break the build (or project integrity). This step can (and it should) be automated using, a continuous integration system like (jenkins with gerrit trigger plugin).  Automation here will save tons of men hours spent on reviewing code that doesn’t compile and/or break unit/integration/system tests.

Second one (Core Review +2) means that somebody from the team spent some time on reviewing and understanding the change. And this particular person didn’t found issues in it and thinks that this change is ready for production.

This set of rules seams to be reasonable and will be sufficient for “most” of the projects. But it has some flows, indirectly build in.

First of all there is no condition on the person that is giving the CR+2. In this case, change author can submit his own change, because there is no condition that would block him from doing so.

Also if you would like to enforce more strict review rules for given project. eg. at least two CR+2 are required to submit a change. You will probably end up with ‘internal convention’ not something that can be enforced automatically by Gerrit.

Of course, one can say that those two cases are exotic. Yes, in a way they are. But my point here is that default Gerrit submit rules are OK for (let say) 90% of projects. Projects that fallow Android OpenSource Project review principles (they can even don’t know that they fallow them ;)).

What is with rest 10%?

No, they are not forgotten by Gerrit… but they have a bit harder live at the beginning.

Why it is harder? Because of Prolog.

Gerrit gives you a tool for defining your own Submit Rules per project. But the entry point is (I would personally say) high.

To define your own Submit Rules one need to learn Prolog programming language, then understood Gerrit Prolog API and finally define such custom Submit Rules per each project in refes/meta/config branch.

This is awesome! Show me a tool that have such flexibility build in, ready to use … and it is free? Yes, entry level is high but, come on, this is one time investment and you are set for (almost) a live time… 😉

But maybe we could do something better here? Maybe we are missing something here… maybe we are not looking abstract enough.

Let me compare code review process to standard build process. In both cases you have some steps that need to be accomplished before you move to next mile stone. In build first of all source code files need to be compiled, same goes for test source files in next step. After that tests are run, and when they pass successfully, project can be packaged and put into production.

Same goes for the review process. First of all change need to be verified (compiled and tested) then team members are looking on code and if they found issues with it, change must be reworked. If not, it can be “packaged” to “production” I mean, merged to branch.

If we  use such approach, then maybe instead of writing code for review rules, we could have a configuration file. Why not put the configuration and convention over Prolog code?

Provided that we would have  such configuration syntax in place, then we could define set of rules that will verify the configuration file. Then wring UI for generating such config file shouldn’t be so hard (compared to generating Prolog code).

What if…

OK, lets finish with those “what if’s” because there is noting to wishful thinking. Why? Because we  already implemented such ‘configuration over Prolog code’ approach in CollabNet. This is what we called Quality Gate wizard.

It contains two key parts:

  1. Quality Gate Gerrit Backend plugin – that adds special Prolog fact capable of understanding XML based configuration parameter.
  2. Quality Gate RCP Wizard – Eclipse based desktop application (build into GitEye app) that allow you use one of 15 predefined rules, define new submit and edit existing one. Then  upload that to Gerrit. Everything from your desktop, no command line, text editor or git command is involved in that process.

More information about Quality Gates can be found in our blog posts 1 2 3

Learning Gerrit Code Review by Luca Milanesio

It is finally there! The idea behind this book was mentioned many times during the Gerrit  community meetups and finally Luca made it a reality! The Gerrit book is out there and it is pretty good read!Learning Gerrit Code Review book cover

I had an opportunity to go through this book and I must admit that this is a fully complete guide to Gerrit. You will learn not only how to use Gerrit, how to create, publish and submit reviews, but also how to setup Gerrit from scratch, integrate it with Jenkins/Hudson, GitHub and your corporate Single Sign On mechanism. Moreover, there is even an example configuration for Apache reverse proxy! If you are not familiar with Git Version Control System, you can even find there essential information regarding this matter. In other words, this is an exhaustive introduction to Gerrit.

In the book you will find an example of a code review workflow with a detailed description how things work in Gerrit, why and where to put ‘Change-Id’ as well as why it is so important for Gerrit. Apart from that, you will learn about Gerrit’s terminology and conventions used in the community such as WIP, RFC, ‘nit’.

All in all, if you are planning to start yours journey through code reviews with Gerrit, this is the position that I can highly recommend for you.

Cool Git stuff from CollabNet Potsdam team

During my git trainings I often say that Git is land of freedom, and this is really true. Not many version control system would allow you to change something in history or permanently delete branch or tag. Git some times will prevent you from doing bad stuff, but you can easily say “shut up, I know what I’m doing” just by passing “force” flag (-f). Here I’m thinking about “force push” (aka “history rewrite”) when you can change something in repository history.

Local history rewrite is really useful when you are crafting yours commits. You can easily rearrange them, edit theirs content and commit message by using “rebase interactive”. I’m using this functionality on daily basis and cannot image working without freedom which it gives!

When we are talking about ability to rewrite remote history some people get really scared, especially in large organizations or those that needs to fallow some strict rules like banks and government orgs. From one hand Git and its “SHA-1 checksumming” ensures them that repository wasn’t changed … but from other hand Git allows changing something in past, of curse such change would be quickly spotted and can be fixed. Simple thought about occurrence of such event scares many enterprise companies, especially when they somehow find out about incident in Eclipse Foundation where almost all branches was accidentally deleted.

One of my first tasks in CollabNet was to provides a safety net against force pushes and branch deletion in Git. Our idea was to provide mechanism that could be easily activated and deactivated, will be accessible for regular users and administrators (regular user can resurrect rewritten history and deleted branch, administrators also can do that but also can permanently remove those entries) and protect whole (even deleted and rewritten history) against Git garbage collection. Base on those assumptions we come up with History Protection mechanism.  If you want know more about it you can watch our short movie or read my other blog post. There is lots more cool Git Enterprise features coming from my CollabNet’s team in Potsdam 😉

Gerrit User Summit and Hackathon, Eclipse DemoCamp Poznan

Last two weeks (8-23 November 2012) was really exhausting, first Gerrit User Summit and Hackathon in Google HQ, then on Thursday (22nd November) Eclipse DemoCamp in Poznan.

First things first: Gerrit User Summit.

This was two-day event in one of Google’s training center. I was really impressed how vibrant Gerrit community is; to be honest I didn’t expect so may people attending to this event and be so active during presentations. There was people not only from Android-oriented companies but also organizations like WikiMedia and hardware companies like Qualcomm or Garmin. First User Summit day includes presentations about server side plugins and improvements in Gerrit 2.5. Second day was mostly occupied by Prolog presentations, I’m really impressed how powerful Prolog rules are and now they can customize Gerrit workflow (eg. you can force at least two +1 votes before change can be submitted, or prevent author from submitting his own change or choose another submit type base on branch name). This day also includes my presentation about Web UI plugins. I’ve presented how simple it is to generate stub GWT and JavaScript based plugin projects, then how easily they can be build and deployed in Gerrit. Currently UI plugis are pretty limited, they can be loaded into UI and say ‘hello’, nothing more but IMO this is good starting point to further development. My slides can be found here.

Then Gerrit Hackathon begins.

Up to 15 persons was hacking Gerrit starting from 12th November. Most of them was focused on improving existing UI and extending its functionality. Useful features were added like:

  • editing topic branch name and commit message in place,
  • configurable dashboards,
  • customizable top level menus,
  • file level comments

were added. Gerrit get also new white look and feel and most of GWT RPC services was rewritten to be REST. My personal focus was on auth-plugins and together with Colby Ranger (Google) and Luca Milanesio (GerritForge) was working on this topic. During first two days we manage to come with draft API and first prototype implementation for handling authentication during git clone commands (using HTTP and SSH protocols). Then move to porting LDAP based authentication and switching Web UI interface to new implementation, unfortunate this appear to be not so easy. Couple hours before hackathon ends we presented hackish implementation that works (in our simple use case) now we need to polish it and make workable for all different kind of use cases 😉

I want to thank here Shawn Pearce for organizing those two awesome events and Google for hosting us in theirs headquarters. Also many thanks to all great developers that I had opportunity talk and code with during User Summit and Haskaton. Hope to see you all at next Gerrit Hackatahon and User Summit.

Eclipse DemoCamp Poznań

Next on my road map was Eclipse DemoCamp in Poznan, this is almost like a tradition that I’m participating in this event, some times as a attendee, some times as speaker. This time I was presenting short introduction to Gerrit. It went well, I got some questions during presentation and afterwards. It appears that Gerrit is already used in some companies in Poznań also some persons from audience was interested in adopting it in theirs organization.

As usually, DemoCamp in Poznań was a great opportunity to meet and chat with my old Eclipse friends: Krzysztof Daniel, Jacek Laskowski, Łukasz Stachowiak, Jacek Pospychała, Natalia Klimasz and others.

Many thanks for organizers (Łukasz Stachowiak and Natalia Klimasz) for organizing yet another great DemoCamp in Poznań. See you all next time! ;D