955 Commits

Author SHA1 Message Date
David Pursehouse
1a4ff2f233 Merge branch 'stable-2.13'
* stable-2.13:
  SetMembersCommand: Handle REST errors gracefully

Change-Id: I59cdf98ef4d24fa3f97fb4faaf7964b03b99b454
2016-11-04 19:24:42 +09:00
David Pursehouse
664a284bc6 SetMembersCommand: Handle REST errors gracefully
If a REST error occurs while adding a member or group to a group, the
command fails with "internal server error" which is not helpful to the
user.

Catch REST errors and allow them to be reported back to the user.

Other types of error will still result in "internal server error".

Change-Id: Ia21f7aa28212f6d93ec4e6ff74a9de9ee6428a00
2016-11-04 10:21:06 +09:00
Hugo Arès
18d8f00aeb Remove unused import
Change-Id: I5799cb58ec1cc2d01914a8633a3e6047fc6ff781
2016-11-03 09:34:30 -04:00
Luca Milanesio
e624bc00f5 ChangeArgumentParser: Replace FluentIterable with Java 8 stream
Change-Id: I34dbf535241a604089ddb5d3af570c4b97c5cc2e
2016-11-02 17:40:59 +09:00
David Pursehouse
34c0481f47 Merge branch 'stable-2.13'
* stable-2.13:
  Fix to reindex a change via SSH: get from DB/Notes instead of Lucene
  Update git submodules
  Fix Postgresql JDBC driver leaking memory
  Fix Schema_127 for mysql on case-sensitive FS
  Update git submodules

Change-Id: Ida6a895ccb8cab2c68bb0cdb83fe4d076f2b007c
2016-11-02 17:36:09 +09:00
Luca Milanesio
7bcb71def6 Fix to reindex a change via SSH: get from DB/Notes instead of Lucene
When reindexing a change via SSH, we need to avoid using the
Lucene index to decode the change-id into a ChangeControl.

The rationale stays in the typical use-case of the reindex itself:
if we need to recreate the Lucene index entry we cannot rely on
a Lucene query to find it.

Change-Id: I34dbf535241a604089ddb5d3af570c4b97c5cc2e
2016-11-02 08:05:43 +00:00
David Pursehouse
ef6398e9d0 Upgrade Guava to 20.0-rc1
The propagate and propagateIfPossible methods are deprecated. Replace
them with the recommended alternatives.

Change-Id: I9107dc51b968e2acc453502ece3c5ed5dd58b5de
2016-10-24 23:46:14 +09:00
Hugo Arès
cf4a2010d6 Merge branch 'stable-2.13'
* stable-2.13:
  Update 2.13.1 release notes
  Catch exceptions from StreamEvents JSON Serialization
  Set version to 2.13.1
  Add 2.13.1 release notes

Change-Id: Ida2a689a71c4f7b94a057bd53cc47c8329d9b015
2016-09-23 16:02:53 +02:00
Gustaf Lundh
e698965e20 Catch exceptions from StreamEvents JSON Serialization
Sometimes GSONs JSON serialization method would fail, allowing the
exception to travel up to the event dispatcher and deregister the
listening user, without any logs identicating an issue.

The user would still be connected over SSH, not knowing something
went wrong.

Catch the exception, log it, and allow the stream-event to continue
serving events.

Change-Id: I4b1d4db6934566f1213ebc2e416dd95c1b0b07e6
2016-09-23 15:44:53 +02:00
Dave Borowitz
a62dc20d7f Convert some Functions/Predicates to streams & lambdas (5)
Change-Id: I4eca94928d77a15a81678dcd91b8d6174b4f6ec3
2016-09-21 04:27:43 -04:00
Gustaf Lundh
aa5d14be3e BaseCommand: Removed unused checkExclusivity method
checkExclusivity is unused since change Ic4a6ea6ff2.

Change-Id: Idbfbb439b3d7a5177b52f042121dca3c357e988f
2016-09-21 07:47:31 +00:00
David Ostrovsky
0b774c478e Update Buck to latest version
This version fixed a major issue: [1] that was a reason of frustration
of many plugin developers: Not cache sources files under symbolic link.
Now for all such source files, the warning is issued:

"
Disabling caching for target //plugins/wip:wip__plugin, because one or
more input files are under a symbolic link
({plugins/wip=/home/davido/projects/wip}). This will severely impact
performance! To resolve this, use separate rules and declare
dependencies instead of using symbolic links.
"

To suppress this warning we add project.allow_symlink option. This
doesn't have any impact for gerrit core but silences the warning above
when plugins are built in gerrit tree mode.

As pointed out in this issue: [2], we are using some artifacts as source
to the java_library() rule as well as binary_jar for prebuilt_ja rule.
To avoid the warning, we rename sources to have "-sources.jar" suffix
and we rename *.zip to end with .jar in other places.

"
Assuming edit.src.zip is a JAR and renaming to edit.src.jar in
//gerrit-patch-jgit:edit_src. Change the extension of the binary_jar to
'.jar' to remove this warning.
"

source_under_test attribute was removed from java_test() rule.
Replication and cookbook-plugin are updated as well.

local.properties support was removed, but we use it only for download
process customization in our own python script, so that we can keep it
usage and not need to move it to .buckconfig.local.

[1] https://github.com/facebook/buck/issues/341
[2] https://github.com/facebook/buck/issues/855

Change-Id: Idf76cc71c21df43e808179b645f9175767b322a8
2016-09-20 13:19:15 +02:00
Stefan Beller
d96c3e5986 Move GetArchive.AllowedFormats to its own file
Change-Id: I999ed908d587ff9af91715c488b944de5254fac4
2016-09-14 10:05:11 -07:00
Edwin Kempin
407fca3cc2 Support notify option for delete reviewer REST endpoint
Some automated tools may want to suppress email notifications when
removing reviewers.

Change-Id: I26f66272d4f871aae9d36f3524faea9ffa86ea35
Signed-off-by: Edwin Kempin <ekempin@google.com>
2016-08-29 13:08:18 +02:00
Dave Borowitz
e1767e5ad7 Revert "Remove usage of to-be-deprecated Throwables"
Guava snapshot is gone.

This reverts commit 8df8a2489d95726a899a4642e72ff4dcce63ee37.

Change-Id: I1f6f40a824e39240d67da9b305bdc8144505e7bf
2016-08-25 00:09:01 +00:00
Scott Dial
7c707175cf Add configuration of key exchange algorithms for sshd
Add new config key "sshd.kex". The default and supported values are:

  1. ecdh-sha2-nistp521
  2. ecdh-sha2-nistp384
  3. ecdh-sha2-nistp256
  4. diffie-hellman-group-exchange-sha256
  5. diffie-hellman-group-exchange-sha1,
  6. diffie-hellman-group14-sha1
  7. diffie-hellman-group1-sha1

With Bouncy Castle installed, all of the above are supported (previously
only 6 and 7). With JCE, only 7 is available.

Bug: Issue 3517
Change-Id: I6b44e88dc4a0ff8f693f21510aba30546bf4cd99
(cherry picked from commit b4a04fa1c5d5ab6e87ac5cd2a046395090cf163f)
2016-08-24 11:06:30 +00:00
David Pursehouse
3f34c3fefe Merge "Add configuration of key exchange algorithms for sshd" 2016-08-24 04:02:59 +00:00
David Pursehouse
8df8a2489d Remove usage of to-be-deprecated Throwables
The propagate and propagateIfPossible methods will be deprecated
in Guava 20. Replace them with the recommended alternatives.

Change-Id: I1c8d19aac5434c938ee10af88766af14e5e4d023
2016-08-19 23:02:10 +09:00
Dave Borowitz
040c39bcb3 Fix auto-adding reviewers during push
When we converted ReceiveCommits to use BatchUpdate's parallel
functionality in I40545a4d, we lost the automatic request scope
propagation. This was mostly fine, with the notable exception of:
 - pushing a new patch set of an existing change, and
 - pushing multiple changes so work is in a background thread, and
 - mentioning a user in a footer (Signed-Off-By, etc.), and
 - not including an email address in that footer, and
 - not having the account index enabled.

This would cause AccountResolver to try to call its
Provider<ReviewDb>, which fails because it's not in request scope.

Fix this by passing a ReviewDb into AccountResolver methods. That was
the easy part; the hard part was figuring out how to write a test case
that triggered this. Since the account index is now enabled by
default, this means putting a test-only hack into LuceneIndexModule
to support disabling a specific index. (This could also be useful for
other tests, since we currently don't exercise the non-index
fallbacks.)

Change-Id: I7231be3ea4660c9ee27f09994706b39ee622488a
2016-08-15 09:58:14 +09:00
Edwin Kempin
447bcdfffc Merge "ShowConnections: Only show start and idle columns for mina backend" 2016-08-04 06:09:28 +00:00
David Pursehouse
a407a3fb5b ShowConnections: Only show start and idle columns for mina backend
The nio2 backend does not provide these data, so displaying dummy
values can confuse users.

Modify the command to only show those columns when the backend is
mina, which does support them.

Change-Id: I889339a4811e38c1b02211983bde6b6e017cd600
2016-08-04 05:55:37 +00:00
David Pursehouse
2b2c3dd55a Merge branch 'stable-2.12'
* stable-2.12:
  Set uploader for inline edit
  Update 2.12.4 release notes
  SshDaemon: Set up the session timeout to make sshd.idleTimeout work
  Attach sources for sshd-core and mina-core

Change-Id: I651e8901f96646660790a7ef6a14275f6d94343c
2016-08-04 11:18:01 +09:00
Hugo Arès
c66120af5a Merge "Add an optional flag to force an online reindex" 2016-08-03 13:18:35 +00:00
David Pursehouse
b150ce534a SshDaemon: Set up the session timeout to make sshd.idleTimeout work
SshServer#start() sets up the session timeout by calling:

  setupSessionTimeout(sessionFactory);

but SshDaemon overrides the start() method, does not call super(), and
does not call setupSessionTimeout.

Therefore, no session timeout is set up on ssh sessions, and sessions
continue to be kept open beyond the timeout specified in the configured
sshd.idleTimeout.

Change-Id: Ia72980d3f0f700386f62d301164f61f32405528e
2016-08-03 18:06:25 +09:00
Khai Do
b9a5d00e15 Add an optional flag to force an online reindex
As discussed on Gerrit ML[1] and in referenced issue, there are
situations where you may want to run an online reindex besides
the upgrade gerrit use case.  This change allows users to force an
online reindex.

[1] https://groups.google.com/d/msg/repo-discuss/pUn8fHVh58w/icsSFef2CAAJ

feature: issue 3987
Change-Id: Ie88b7effda08996f7c0f325543be703bcf09c794
2016-08-02 14:09:12 -07:00
Hugo Arès
41b4c0d3da Add extension point to register JGit PostUploadHooks
Plugins may register PostUploadHook instances in order to get notified
after JGit is done uploading a pack.

Now that PostUploadHook can be registered using the DynamicSet, use that
mechanism to register UploadPackMetricsHook.

Change-Id: If848bddc85ca8923a5d55f7dd448ac218c910e1c
2016-08-02 15:32:08 -04:00
Edwin Kempin
ece1d7db72 Merge "SSH show-queue: option to group output by queue and print queue info" 2016-07-14 07:15:15 +00:00
Saša Živkov
eaf64568a7 SSH show-queue: option to group output by queue and print queue info
When the new option --by-queue is used the output of the show-queue
command is grouped by the work queue. Queue name is printed on top of
the tasks list and the number of worker threads assigned to that thread
pool is printed in the summary line. This option should help Gerrit admins
to identify which thread pools need to be adjusted.

For comparison, here is an example output without the new --by-queue option:

  Task     State        StartTime         Command
  ------------------------------------------------------------------------------
  9d51b721              16:29:14.750      git-upload-pack '/gerrit' (admin)
  18fr4561              16:29:14.750      git-upload-pack '/gerrit' (admin)
  ad52b823              16:29:14.750      git-upload-pack '/gerrit' (admin)
  bd51bbcc              16:29:14.750      git-upload-pack '/gerrit' (admin)
  11223344              16:29:14.750      git-upload-pack '/gerrit' (admin)
  3d120b5c 17:28:20.169 16:28:20.169      Log File Compressor
  ------------------------------------------------------------------------------
    6 tasks

With the --by-queue option the output looks like:

  $ ssh -p29418 admin@localhost gerrit show-queue -w --by-queue
  Task     State        StartTime         Command
  ------------------------------------------------------------------------------
  Queue: SSH-Interactive-Worker
  9d51b721              16:29:14.750      git-upload-pack '/gerrit' (admin)
  18fr4561              16:29:14.750      git-upload-pack '/gerrit' (admin)
  ad52b823              16:29:14.750      git-upload-pack '/gerrit' (admin)
  bd51bbcc              16:29:14.750      git-upload-pack '/gerrit' (admin)
  11223344              16:29:14.750      git-upload-pack '/gerrit' (admin)
  ------------------------------------------------------------------------------
    5 tasks, 14 worker threads

  Queue: WorkQueue
  3d120b5c 17:28:20.169 16:28:20.169      Log File Compressor
  ------------------------------------------------------------------------------
    1 tasks, 1 worker threads

Change-Id: If82bdb50702f2001f887fe5004b0d80b61131a90
2016-07-13 18:24:55 +02:00
Dave Borowitz
d25fb550e4 Merge "Unwrap db in ssh.commands.QueryShell" 2016-07-12 16:15:13 +00:00
David Pursehouse
89634f70f3 ReviewInput: Split NotifyHandling out to a separate file
NotifyHandling is used for other purposes than adding a review, so
it doesn't really belong in ReviewInput.

Change-Id: I49ce1952eab0a75c8466a871fcc690a94b14e058
2016-07-12 17:24:35 +09:00
Björn Pedersen
484bf3cae1 Unwrap db in ssh.commands.QueryShell
If NoteDb reads are enabled then the gsql ssh commands fails with

fatal: internal server error

due to DisabledChangesReviewDbWrapper (see Issue 4247).

As not all tables are migrated yet, it makes sense to still allow
low-level access to the db.

Bug: Issue 4247
Change-Id: Icebe51f470010d913f387bb98f7319616dd89aba
2016-07-12 08:55:59 +02:00
Zhen Chen
10c815d2e1 Refactor ProjectControl#canReadCommmit to take repository as a parameter
Two reasons:
1. Reusing an existing RevWalk to call isMergedInto or similar on it can
corrupt the state in the caller, see I0d242362.
2. The repository is already open before calling this method.

Pass the Repo instead of RevWalk and create a new clean RevWalk from the
Repo.

Change-Id: I00a6d9061d4c690c236e739b29b66b79427cd47b
2016-07-11 12:37:23 -07:00
Eryk Szymanski
a26067f126 StreamEvents: Correctly serialize Project.NameKey elements in json
Add a ProjectNameKeySerializer so that the project attribute gets
serialized correctly in the json output, i.e.:

  "project":"project-name"

instead of:

  "project": { "name" : "project-name" }

Change-Id: I96dbb4c38f2da506165d5905a9edd8f01a87c899
Signed-off-by: Eryk Szymanski <eryksz@gmail.com>
2016-07-11 12:22:36 +09:00
Edwin Kempin
a62673ca77 Accounts API: Add methods to create an account
Change-Id: I798f98384fc513987c00aa1a6102c9967813b542
Signed-off-by: Edwin Kempin <ekempin@google.com>
2016-07-06 17:00:22 +02:00
Scott Dial
b4a04fa1c5 Add configuration of key exchange algorithms for sshd
Add new config key "sshd.kex". The default and supported values are:

  1. ecdh-sha2-nistp521
  2. ecdh-sha2-nistp384
  3. ecdh-sha2-nistp256
  4. diffie-hellman-group-exchange-sha256
  5. diffie-hellman-group-exchange-sha1,
  6. diffie-hellman-group14-sha1
  7. diffie-hellman-group1-sha1

With Bouncy Castle installed, all of the above are supported (previously
only 6 and 7). With JCE, only 7 is available.

Bug: Issue 3517
Change-Id: I6b44e88dc4a0ff8f693f21510aba30546bf4cd99
2016-07-05 15:29:04 +09:00
Edwin Kempin
b644ff8fcf Merge "Implement Bazel build" 2016-06-24 10:51:33 +00:00
Edwin Kempin
94732bfa19 Reindex account whenever account is evicted from cache
Change-Id: I025cabc9be98628777066cda7aa97186f5a0da15
Signed-off-by: Edwin Kempin <ekempin@google.com>
2016-06-22 16:55:32 +02:00
David Pursehouse
8219d818a7 PutConfig: move static inner Input class to extension API
Also rename the existing PutDescriptionInput to DescriptionInput.

Change-Id: I8291e970353b8ae6ed4f0cbe5dce746007e25291
2016-06-21 16:30:43 +09:00
David Ostrovsky
b81b4f75ae Implement Bazel build
To run the tests:

  bazel test //...

To build the Gerrit plugin API, run:

  bazel build gerrit-plugin-api:plugin-api_deploy.jar

To build the Gerrit extension API, run:

  bazel build gerrit-extension-api:extension-api_deploy.jar

TODOs:

Licenses
Reduce visibility (all public for now)
Generate HTML Documentation
Core plugins
gerrit_plugin() rule to build plugins in tree and standalone modes
GWT UI (only gwt_module() skylark rule is provided, no gwt_binary())
PolyGerrit UI
WAR
Publish artifacts to Maven Central
Ask Bazel team to add Gerrit to their CI on ci.bazel.io

Contributed-By: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I9a86e670882a44a5c966579cdeb8ed79b1590de3
2016-06-14 21:12:02 +02:00
Jonathan Nieder
b273cfd04d Consistently annotate changeCache as @Nullable
The changeCache is null when in the context of BatchProgramModule.
The only consumer of changeCache, VisibleRefFilter, is prepared to
handle a null value, so in all code paths it is okay for it to be
null.

This makes reindex work again.  Regression introduced in
a758640bc33c20cead19b86a32db075c776c4140 (VisibleRefFilter: Avoid
touching the database for drafts, 2016-06-03):

 $ java -jar buck-out/gen/gerrit/gerrit.war reindex -d ../gerrit-testsite
[...]
 Reindexing changes: projects: 66% (2/3)[2016-06-06 16:18:36,781] [Index-Batch-3] WARN  com.google.gerrit.server.index.change.AllChangesIndexer : Failed to index change 18
 com.google.inject.ProvisionException: Unable to provision, see the following errors:

 1) null returned by binding at com.google.gerrit.pgm.util.BatchProgramModule.configure(BatchProgramModule.java:126)
  but parameter 8 of com.google.gerrit.server.project.ProjectControl.<init>() is not @Nullable
   while locating com.google.gerrit.server.git.SearchingChangeCacheImpl
     for parameter 8 at com.google.gerrit.server.project.ProjectControl.<init>(ProjectControl.java:177)
   while locating com.google.gerrit.server.project.ProjectControl annotated with @com.google.inject.internal.UniqueAnnotations$Internal(value=4)

Reported-by: Viktar Donich <viktard@google.com>
Change-Id: Ia0ca0e0e153c9f357e5ebc6edf4b1962a2490f2d
2016-06-06 18:50:47 -07:00
Dave Borowitz
02167dbee7 Merge changes I64000a57,Icc7c7586
* changes:
  ChangeIndexer: Disable auto-rebuilding changes
  ChangeNotes: Log when recheckUpToDate finds it wasn't
2016-06-06 19:19:38 +00:00
Dave Borowitz
a758640bc3 VisibleRefFilter Avoid touching the database for drafts
This is an analogous problem to the one with search results fixed in
Ie54b9e2d. VisibleRefFilter is a little trickier because it was using
ChangeCache, which only returned Changes, not the reviewer set. Change
SearchingChangeCacheImpl to cache a different value type and return
ChangeDatas from its search method so we can use the cached
ReviewerSet where appropriate.

Unfortunately for the Reindex program we still need to support not
having a SearchingChangeCacheImpl, which means we have a completely
separate codepath for reading changes from the database.

Change-Id: Ic432a8e48a2bafc8d142b84b25101d95ffb674b7
2016-06-06 12:42:38 -04:00
Dave Borowitz
a6ec1245b4 ChangeIndexer: Disable auto-rebuilding changes
When a DFS ref update of a NoteDb meta ref fails due to a transient
error in the storage backend, we don't want to incur an additional
write to the ref during reindexing, as it may just fail again. Worse,
while BatchUpdate knows to ignore NoteDb write updates when executing
its NoteDbUpdateManager, it can't as easily ignore them while getting
its index futures. Thus an error that was successfully ignored is
likely to be followed by one that can't be.

Work around this for the case of NoteDb writes enabled but reads
disabled, by explicitly turning off auto-rebuilding from
ChangeIndexer. This doesn't help us in the case of NoteDb reads being
enabled, where we have to be able to read the latest NoteDb data from
the ref in order to reindex.

Change-Id: I64000a57ffcf73a9cbef42a6130e1fb4bc8e98f0
2016-06-06 11:22:27 -04:00
David Pursehouse
323247227d Enable and fix 'Statement unnecessarily nested within else clause' warnings
Change-Id: Ida6df4593fc2ab3c11581309b2b4a638229ea093
2016-06-02 10:20:37 +09:00
David Pursehouse
3f99e4e96f Initial implementation of SSH command to index changes
The initial implementation allows to index specified changes. In future
this could be extended to allow indexing of changes by project/branch.

Change-Id: Ia66b086b8bd8d49fe536332d96e3292087fefa01
2016-05-26 16:57:00 +09:00
David Pursehouse
e643ae86b3 SetReviewersCommand: Factor code out to ChangeArgumentParser
Factor code to parse changes from the argument list out to a new
utility class.

Change-Id: I277981f3128d9f958eda2e8ebc7d5d2ca988d18c
2016-05-26 13:49:09 +09:00
David Pursehouse
9dbf755935 Remove 'runsAt = MASTER' from @CommandMetaData annotations
MASTER is the default and does not need to be explicitly specified.

Change-Id: I3dd5812fc7065085d6f668f36548898343e38322
2016-05-25 15:07:19 +00:00
David Pursehouse
b553a48f3b SetReviewersCommand: Fix metaVar for arguments
Change-Id: Ib2c6e7776605b6dad7656b096c6c735dafc6b84b
2016-05-25 15:07:07 +00:00
David Pursehouse
64d0b4cad6 BaseCommand: Add writeError utility method
Move writeError from SetReviewersCommand to BaseCommand. Remove the
similar method from ReviewCommand and adapt the code to the slightly
different signature.

Change-Id: Ie6f326198ff87892f2f7dd6b1ec309d24cb35549
2016-05-25 15:06:32 +00:00
David Pursehouse
34a238048c Consolidate error reporting in SSH commands
Make the commands use the "die" method from BaseCommand, where possible.

Change-Id: I5d2e4d03d59fa62ec988b1e68c60072c5981c10f
2016-05-25 11:00:54 +09:00