Always replicate changes regardless of the permissions It isn't possible to perform any permission-based selection of the changes to replicate: pull replication cannot access the change meta-data until the 'meta' ref gets replicated, therefore it isn't possible to check their visibility beforehand. Add also more logs on the reasons why a replication event will not be replicated. Bug: Issue 13758 Change-Id: Iffed49e90ab175dcc9585764fb9015e487a365c9
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java index e9bb620..0d4c57d 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java
@@ -293,27 +293,50 @@ try { projectState = projectCache.checkedGet(project); } catch (IOException e) { + repLog.warn( + "NOT scheduling replication {}:{} because could not open source project", + project, + ref, + e); return false; } if (projectState == null) { + repLog.warn( + "NOT scheduling replication {}:{} because project does not exist", + project, + ref); throw new NoSuchProjectException(project); } if (!projectState.statePermitsRead()) { + repLog.warn( + "NOT scheduling replication {}:{} because project is not readable", + project, + ref); return false; } if (!shouldReplicate(projectState, userProvider.get())) { + repLog.warn( + "NOT scheduling replication {}:{} because project is supposed to be replicated", + project, + ref); return false; } if (FetchOne.ALL_REFS.equals(ref)) { return true; } try { - permissionBackend - .user(userProvider.get()) - .project(project) - .ref(ref) - .check(RefPermission.READ); + if (!ref.startsWith(RefNames.REFS_CHANGES)) { + permissionBackend + .user(userProvider.get()) + .project(project) + .ref(ref) + .check(RefPermission.READ); + } } catch (AuthException e) { + repLog.warn( + "NOT scheduling replication {}:{} because lack of permissions to access project/ref", + project, + ref); return false; } return true; @@ -326,6 +349,7 @@ Throwables.throwIfUnchecked(e); throw new RuntimeException(e); } + repLog.warn("NOT scheduling replication {}:{}", project, ref); return false; }