Gerrit

From Wikitech
(Difference between revisions)
Jump to: navigation, search
(Giving users Labs access, if they don't already have SVN access)
(Explain why robots.txt denies everything.)
 
(24 intermediate revisions by 7 users not shown)
Line 1: Line 1:
* [http://gerrit-documentation.googlecode.com/svn/Documentation/2.2.1/index.html Upstream documentation for Gerrit 2.2.1]
+
We use Gerrit for our code review system for Git. It supersedes the CodeReview extension.
  
Gerrit is installed on [[formey]] in the prefix /var/lib/gerrit2.  
+
== Quick links ==
 +
* [https://gerrit.wikimedia.org Gerrit]
 +
* [https://gerrit.wikimedia.org/r/Documentation/index.html Built-in Gerrit documentation]
 +
* [http://gerrit-dev.wmflabs.org Gerrit test install (labs)]
  
It is a Java daemon which listens for HTTP connections (port 8080) and SSH connections (port 29418). Apache on formey proxies the relevant URLs on port 80 and 443 through to Gerrit. The SSH port provides a restricted shell for Git checkouts and administrative commands.
+
== Details ==
 +
Gerrit is installed on [[manganese]] in the prefix <tt>/var/lib/gerrit2</tt>. A slave instance runs on [[formey]] for fallover purposes.
  
It uses the misc DB server (db9/db10), database name "reviewdb", for most storage.  
+
It is a Java daemon which listens for HTTP connections (port 8080) and SSH connections (port 29418).  Apache on manganese proxies the relevant URLs on port 80 and 443 through to Gerrit. The SSH port provides a restricted shell for Git checkouts and administrative commands.
  
It uses the LDAP instance shared with [[subversion]] and [[labs]], possibly on virt0.wikimedia.org, for authentication. Accounts under <tt>ou=people,dc=wikimedia,dc=org</tt> and groups under <tt>ou=groups,dc=wikimedia,dc=org</tt> are exposed to Gerrit. The Gerrit account name is the "cn" field in LDAP.
+
It uses the misc DB server (db1048), database name "reviewdb", for most storage. Git repos are on NFS and stored at /var/lib/gerrit2/review_site/git.
  
Gerrit shells out to GitWeb, a Perl application which is installed using the stock package.  
+
It uses the LDAP instance shared with [[subversion]] and [[labs]], possibly on virt0.wikimedia.org, for authentication. Accounts under <tt>ou=people,dc=wikimedia,dc=org</tt> and groups under <tt>ou=groups,dc=wikimedia,dc=org</tt> are exposed to Gerrit. The Gerrit account name is the "cn" field in LDAP.  In order to log in to Gerrit, a user needs to already have a Labs account.  See [https://labsconsole.wikimedia.org/wiki/Help:Access "Help:Access" on the Labsconsole wiki] for the process of getting a Labs account.
  
To find out what version of Gerrit is running, you can use:
+
Gerrit shells out to GitWeb, a Perl application which is installed using the stock package.
  
<pre>
+
To find out what version of Gerrit is running, you can use either of the following two commands:
java -jar /var/lib/gerrit2/gerrit.war version
+
</pre>
+
  
It is 2.2.1 at the time of writing.  
+
java -jar /var/lib/gerrit2/gerrit.war version
 +
ssh -p 29418 gerrit.wikimedia.org gerrit version
  
== Giving users Labs access, if they already have an SVN account ==
+
It is 2.4.2-2-ge9a1970 at the time of writing.
In order to log in to Gerrit, a user needs to already have a Labs account.
+
  
Collect the following information from the user:
+
== Using git ==
  
* Preferred wiki username. This will also be the user's git username, so legal name would be reasonable
+
This is [https://labsconsole.wikimedia.org/wiki/Help:Git documented on the labsconsole wiki] and [[mw:Git/Workflow|on mediawiki.org]].
* Preferred email address
+
* Their svn account name
+
  
On formey, run the following command:
+
== Database install ==
  
add-labs-user --wikiname="<wikiusername>" --mail="<email address>" <svnusername>
+
Database installation is handled by Gerrit installation process, you simply need a user named 'gerrit2' with appropriate privileges. Make sure to set the charset of the database to utf8.
  
Then go to [https://labsconsole.wikimedia.org/wiki/Special:NovaProject Special:NovaProject] and add the user, by wiki username, to the bastion project.
+
Replace <PASSWORD> below and apply:
  
Then the user must do the following:
+
  CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY <PASSWORD>;
 +
  CREATE DATABASE reviewdb;
 +
  ALTER DATABASE reviewdb charset=utf8;
 +
  GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
 +
  FLUSH PRIVILEGES;
  
# Go to the [https://labsconsole.wikimedia.org/wiki/Special:PasswordReset password reset form at labs console]
 
# Use the temporary password to set a password
 
# Log into [https://gerrit.wikimedia.org gerrit]
 
# Add their SSH key
 
  
If they are an ops team member, they should also be added to the ops group:
+
== Upgrading Gerrit ==
 +
# Back up the database (db1048.reviewdb) and git directories (/var/lib/gerrit2/review_site/git/). ''Just In Case.''
 +
# Download the latest .war file from [http://code.google.com/p/gerrit/downloads/list Google Code] to /var/lib/gerrit2/.
 +
# Stop the gerrit daemon (/var/lib/gerrit2/review_site/bin/gerrit.sh stop)
 +
# Start gerrit with the new *.war file using the "init" flag. For example: <tt>cd /var/lib/gerrit2 && java -jar gerrit-2.3.war init -d review_site</tt>
 +
# The updater is going to ask you some questions, keep the current values. When it asks you if you want to copy the *.war file to the bin directory, say ''yes''.
 +
# Run puppet (this will restart gerrit)
 +
# Profit!!
  
modify-ldap-group --addmembers=<svnusername> ops
+
''Note'': You may need to restart gerrit after the upgrade is finished.
  
If they are WMF staff, they should also be added to the wmf group:
+
== Getting the war ==
  
modify-ldap-group --addmembers=<svnusername> wmf
+
We build Gerrit + our plugins from master daily with Jenkins (plus when Chad feels like it). These builds are available from [https://integration.mediawiki.org/nightly/gerrit/wmf/?C=M;O=D integration.mediawiki.org].
  
== Giving users Labs access, if they don't already have SVN access ==
+
Generally speaking, the latest build is what we're running [https://gerrit-dev.wmflabs.org on labs]. This will be the case for production soon too (right now we're using a custom 2.4.2 build).
Ask for:
+
  
* Preferred wiki username. This will also be the user's git username, so legal name would be reasonable
+
== Creating new repositories ==
* Preferred email address
+
* Their preferred shell account name
+
  
Then either:
+
see [[mw:Git/Creating new repositories]]
  
* just get the accountcreators power from Ryan Lane or Sara Smollett or Mutante and then create the user's account using https://labsconsole.wikimedia.org/w/index.php?title=Special:UserLogin&type=signup and choose "By email" to send the user a password
+
== Indexing ==
* [[Svn.wikimedia.org#Add_users|Make an LDAP user on formey]] and then follow the instructions for people who have SVN accounts (above)
+
We disabled indexing by search engines awhile back. Gitweb has awful performance, and the search engines were overloading manganese (mainly from requesting .tar urls from every commit they could dig for). We could possibly revisit this sometime in the future when we've got time to get actual stats (and we've [[bugzilla:38383|replaced Gitweb with Gitblit]]).
  
== Using gerrit ==
+
== See also ==
 
+
* [[gerrit-wm]]
This is [https://labsconsole.wikimedia.org/wiki/Main_Page documented on the labsconsole wiki] and [[mw:Git/Workflow|on mediawiki.org].
+
* [[gerrit.wikimedia.org]]

Latest revision as of 21:37, 11 February 2013

We use Gerrit for our code review system for Git. It supersedes the CodeReview extension.

Contents

[edit] Quick links

[edit] Details

Gerrit is installed on manganese in the prefix /var/lib/gerrit2. A slave instance runs on formey for fallover purposes.

It is a Java daemon which listens for HTTP connections (port 8080) and SSH connections (port 29418). Apache on manganese proxies the relevant URLs on port 80 and 443 through to Gerrit. The SSH port provides a restricted shell for Git checkouts and administrative commands.

It uses the misc DB server (db1048), database name "reviewdb", for most storage. Git repos are on NFS and stored at /var/lib/gerrit2/review_site/git.

It uses the LDAP instance shared with subversion and labs, possibly on virt0.wikimedia.org, for authentication. Accounts under ou=people,dc=wikimedia,dc=org and groups under ou=groups,dc=wikimedia,dc=org are exposed to Gerrit. The Gerrit account name is the "cn" field in LDAP. In order to log in to Gerrit, a user needs to already have a Labs account. See "Help:Access" on the Labsconsole wiki for the process of getting a Labs account.

Gerrit shells out to GitWeb, a Perl application which is installed using the stock package.

To find out what version of Gerrit is running, you can use either of the following two commands:

java -jar /var/lib/gerrit2/gerrit.war version
ssh -p 29418 gerrit.wikimedia.org gerrit version

It is 2.4.2-2-ge9a1970 at the time of writing.

[edit] Using git

This is documented on the labsconsole wiki and on mediawiki.org.

[edit] Database install

Database installation is handled by Gerrit installation process, you simply need a user named 'gerrit2' with appropriate privileges. Make sure to set the charset of the database to utf8.

Replace <PASSWORD> below and apply:

 CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY <PASSWORD>;
 CREATE DATABASE reviewdb;
 ALTER DATABASE reviewdb charset=utf8;
 GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
 FLUSH PRIVILEGES;


[edit] Upgrading Gerrit

  1. Back up the database (db1048.reviewdb) and git directories (/var/lib/gerrit2/review_site/git/). Just In Case.
  2. Download the latest .war file from Google Code to /var/lib/gerrit2/.
  3. Stop the gerrit daemon (/var/lib/gerrit2/review_site/bin/gerrit.sh stop)
  4. Start gerrit with the new *.war file using the "init" flag. For example: cd /var/lib/gerrit2 && java -jar gerrit-2.3.war init -d review_site
  5. The updater is going to ask you some questions, keep the current values. When it asks you if you want to copy the *.war file to the bin directory, say yes.
  6. Run puppet (this will restart gerrit)
  7. Profit!!

Note: You may need to restart gerrit after the upgrade is finished.

[edit] Getting the war

We build Gerrit + our plugins from master daily with Jenkins (plus when Chad feels like it). These builds are available from integration.mediawiki.org.

Generally speaking, the latest build is what we're running on labs. This will be the case for production soon too (right now we're using a custom 2.4.2 build).

[edit] Creating new repositories

see mw:Git/Creating new repositories

[edit] Indexing

We disabled indexing by search engines awhile back. Gitweb has awful performance, and the search engines were overloading manganese (mainly from requesting .tar urls from every commit they could dig for). We could possibly revisit this sometime in the future when we've got time to get actual stats (and we've replaced Gitweb with Gitblit).

[edit] See also

Personal tools
Namespaces

Variants
Actions
Navigation
Ops documentation
Wiki
Toolbox