summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Kelly <doug.kelly@garmin.com>2014-10-03 15:13:11 -0500
committerDoug Kelly <dougk.ff7@gmail.com>2014-10-16 10:44:48 +0000
commit7c25cd575572410ef90a53d1af853fde7d011bf8 (patch)
tree2585ca008df51561a842593c0b9c1c38efb77b98
parentedce37c18abd21208116bb2c59a4b118c44f34bd (diff)
Prevent creating repos on extra serversv2.9.5v2.9.4v2.9.3v2.9.2upstream/stable-2.9
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
-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 20b0a3f..feff6c0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -200,25 +200,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) {
- stateLog.error(String.format(
- "source project %s not available", project), err, state);
- return;
+ stateLog.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;
@@ -380,7 +384,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;