Merge "Remove double-binding of the ProjectVersionRefUpdateImpl to EventListener" into stable-3.7
diff --git a/docker-compose.kafka-broker.yaml b/docker-compose.kafka-broker.yaml
deleted file mode 100644
index d3fc713..0000000
--- a/docker-compose.kafka-broker.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-version: '3'
-services:
- zookeeper:
- image: wurstmeister/zookeeper:latest
- ports:
- - "2181:2181"
- kafka:
- image: wurstmeister/kafka:2.13-2.6.3
- ports:
- - "9092:9092"
- environment:
- KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1
- KAFKA_CREATE_TOPICS: "gerrit:1:1"
- KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
diff --git a/e2e-tests/docker-compose-kafka.yaml b/e2e-tests/docker-compose-kafka.yaml
index addb8d5..b02b58d 100644
--- a/e2e-tests/docker-compose-kafka.yaml
+++ b/e2e-tests/docker-compose-kafka.yaml
@@ -1,12 +1,11 @@
version: '3'
services:
kafka:
- image: wurstmeister/kafka:2.13-2.6.3
+ image: bitnami/kafka:3.6.0
depends_on:
- zookeeper
environment:
- KAFKA_ADVERTISED_HOST_NAME: kafka
- KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
+ - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
gerrit1:
depends_on:
diff --git a/e2e-tests/docker-compose.yaml b/e2e-tests/docker-compose.yaml
index 3abb757..2ac7b06 100644
--- a/e2e-tests/docker-compose.yaml
+++ b/e2e-tests/docker-compose.yaml
@@ -1,7 +1,9 @@
version: '3'
services:
zookeeper:
- image: wurstmeister/zookeeper:latest
+ image: bitnami/zookeeper:3.8.3
+ environment:
+ ALLOW_ANONYMOUS_LOGIN: "true"
gerrit1:
image: gerritcodereview/gerrit:${GERRIT_IMAGE}
diff --git a/setup_local_env/configs/gerrit.config b/setup_local_env/configs/gerrit.config
index 8a176f2..20075d7 100644
--- a/setup_local_env/configs/gerrit.config
+++ b/setup_local_env/configs/gerrit.config
@@ -39,8 +39,6 @@
directory = cache
[plugins]
allowRemoteAdmin = true
-[plugin "websession-flatfile"]
- directory = $FAKE_NFS
[plugin "events-kafka"]
sendAsync = true
bootstrapServers = $BROKER_HOST:$BROKER_PORT
diff --git a/setup_local_env/docker-compose-core.yaml b/setup_local_env/docker-compose-core.yaml
index dab168d..f8ef318 100644
--- a/setup_local_env/docker-compose-core.yaml
+++ b/setup_local_env/docker-compose-core.yaml
@@ -1,10 +1,12 @@
version: '3'
services:
zookeeper:
- image: wurstmeister/zookeeper:latest
+ image: bitnami/zookeeper:3.8.3
ports:
- "2181:2181"
container_name: zk_test_node
+ environment:
+ ALLOW_ANONYMOUS_LOGIN: "true"
prometheus:
container_name: prometheus_test_node
image: prom/prometheus:v2.16.0
diff --git a/setup_local_env/docker-compose-kafka.yaml b/setup_local_env/docker-compose-kafka.yaml
index 2a5b0fc..70fda58 100644
--- a/setup_local_env/docker-compose-kafka.yaml
+++ b/setup_local_env/docker-compose-kafka.yaml
@@ -1,13 +1,13 @@
version: '3'
services:
kafka:
- image: wurstmeister/kafka:2.13-2.6.3
+ image: bitnami/kafka:3.6.0
ports:
- "9092:9092"
container_name: kafka_test_node
environment:
- KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1
- KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
+ - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092
+ - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
networks:
- setup_local_env_default
networks:
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java
index 98d1320..3fc57ae 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java
@@ -14,6 +14,7 @@
package com.googlesource.gerrit.plugins.multisite.validation;
+import static com.googlesource.gerrit.plugins.multisite.validation.ProjectVersionRefUpdate.MULTI_SITE_VERSIONING_REF;
import static com.googlesource.gerrit.plugins.replication.pull.PullReplicationLogger.repLog;
import com.gerritforge.gerrit.globalrefdb.GlobalRefDbLockException;
@@ -64,6 +65,9 @@
.filter(ref -> !hasBeenRemovedFromGlobalRefDb(projectName, ref))
.filter(
ref -> {
+ if (shouldNotBeTrackedAnymoreOnGlobalRefDb(ref)) {
+ return true;
+ }
Optional<ObjectId> localRefOid =
getLocalSha1IfEqualsToExistingGlobalRefDb(
repository, projectName, refDb, ref, true);
@@ -76,7 +80,7 @@
ref,
oid.getName()));
- return localRefOid.isEmpty();
+ return !localRefOid.isPresent();
})
.collect(Collectors.toSet());
} catch (IOException ioe) {
@@ -87,6 +91,19 @@
}
}
+ /*
+ * Since ac43a5f94c773c9db7a73d44035961d69d13fa53 the 'refs/multi-site/version' is
+ * not updated anymore on the global-refdb; however, the values stored already
+ * on the global-refdb could get in the way and prevent replication from happening
+ * as expected.
+ *
+ * Exclude the 'refs/multi-site/version' from local vs. global refdb checking
+ * pretending that the global-refdb for that ref did not exist.
+ */
+ private boolean shouldNotBeTrackedAnymoreOnGlobalRefDb(String ref) {
+ return MULTI_SITE_VERSIONING_REF.equals(ref);
+ }
+
/* If the ref to fetch has been set to all zeros on the global-refdb, it means
* that whatever is the situation locally, we do not need to fetch it:
* - If the remote still has it, fetching it will be useless because the global
@@ -129,7 +146,7 @@
.orElse(false))
.map(Ref::getObjectId);
- if (localRefObjectId.isEmpty() && retryWithRandomSleep) {
+ if (!localRefObjectId.isPresent() && retryWithRandomSleep) {
randomSleepForMitigatingConditionWhereLocalRefHaveJustBeenChanged(
projectName, localRefObjectId, ref);
localRefObjectId =
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilterTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilterTest.java
index 9a7a3b3..e09f6f6 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilterTest.java
@@ -170,6 +170,24 @@
}
@Test
+ public void shouldNotFilterOutWhenRefsMultisiteVersionIsPresentInSharedRefDb() throws Exception {
+ String refsMultisiteVersionRef = ProjectVersionRefUpdate.MULTI_SITE_VERSIONING_REF;
+ RevCommit multiSiteVersionRef = newRef(refsMultisiteVersionRef);
+
+ doReturn(Optional.of(multiSiteVersionRef.getId().getName()))
+ .when(sharedRefDatabaseMock)
+ .get(eq(projectName), eq(refsMultisiteVersionRef), eq(String.class));
+
+ Set<String> refsToFetch = Set.of(refsMultisiteVersionRef);
+
+ MultisiteReplicationFetchFilter fetchFilter =
+ new MultisiteReplicationFetchFilter(sharedRefDatabaseMock, gitRepositoryManager, config);
+ Set<String> filteredRefsToFetch = fetchFilter.filter(project, refsToFetch);
+
+ assertThat(filteredRefsToFetch).hasSize(1);
+ }
+
+ @Test
public void shouldFilterOutWhenRefIsDeletedInTheSharedRefDb() throws Exception {
String temporaryOutdated = "refs/heads/temporaryOutdated";
newRef(temporaryOutdated);