summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Kelly <doug.kelly@garmin.com>2014-10-03 15:13:11 -0500
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-07-02 15:06:57 +0000
commit1ba61bb488c953851497439d8784ba69cbfeee7d (patch)
tree5477a681fcc3e3a2d84fa2c0b5e78cf5e35e7458
parentff8e1ca415d9c8efb42939f7bb7fe4fb7319cc13 (diff)
Prevent creating repos on extra serversHEADv2.7.0-based
If using a group to replicate only certain repositories, it is possible to be in a state where the authGroup is used on some servers but not others. If this happened, Gerrit would create the repository on all servers, even if the authGroup would prevent replicating code to it. By ensuring the authGroup can see the project first, we don't create the repository if it's not needed. Bug: Issue 543 Change-Id: I2f189bdb6007228d0b25a6ce9c0357b3f97e4ced (cherry picked from commit 7c25cd575572410ef90a53d1af853fde7d011bf8) Reviewed-by: Ismo Haataja <ismo.haataja@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
index 19a9359..d80da48 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -197,25 +197,29 @@ class Destination {
return cfg.getInt("remote", rc.getName(), name, defValue);
}
- void schedule(final Project.NameKey project, final String ref,
- final URIish uri, ReplicationState state) {
+ private boolean isVisible(final Project.NameKey project,
+ ReplicationState... states) {
try {
- boolean visible = threadScoper.scope(new Callable<Boolean>(){
+ return threadScoper.scope(new Callable<Boolean>() {
@Override
public Boolean call() throws NoSuchProjectException {
return controlFor(project).isVisible();
}
}).call();
- if (!visible) {
- return;
- }
} catch (NoSuchProjectException err) {
- wrappedLog.error(String.format(
- "source project %s not available", project), err, state);
- return;
+ wrappedLog.error(String.format("source project %s not available", project),
+ err, states);
} catch (Exception e) {
throw Throwables.propagate(e);
}
+ return false;
+ }
+
+ void schedule(final Project.NameKey project, final String ref,
+ final URIish uri, ReplicationState state) {
+ if (!isVisible(project, state)) {
+ return;
+ }
if (!replicatePermissions) {
PushOne e;
@@ -377,7 +381,11 @@ class Destination {
}
}
- boolean wouldPushProject(Project.NameKey project) {
+ boolean wouldPushProject(final Project.NameKey project) {
+ if (!isVisible(project)) {
+ return false;
+ }
+
// by default push all projects
if (projects.length < 1) {
return true;