Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(restore): adds --dc-mapping flag to restore command #4213

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ INTEGRATION_TEST_ARGS := -cluster $(PUBLIC_NET)100 \
-managed-cluster $(PUBLIC_NET)11,$(PUBLIC_NET)12,$(PUBLIC_NET)13,$(PUBLIC_NET)21,$(PUBLIC_NET)22,$(PUBLIC_NET)23 \
-test-network $(PUBLIC_NET) \
-managed-second-cluster $(PUBLIC_NET)31,$(PUBLIC_NET)32 \
-managed-third-cluster $(PUBLIC_NET)41,$(PUBLIC_NET)42 \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having 3 clusters for the docker setup seems excessive.
You have written nice unit tests, so we don't need to cover all scenarios with integration tests.
Having said that, could we simply rename the DC in the second cluster (used just for the restore)?
We could even divide this cluster into 2 single nodes DCs if that could help.

-user cassandra -password cassandra \
-agent-auth-token token \
-s3-data-dir ./testing/minio/data -s3-provider Minio -s3-endpoint $(MINIO_ENDPOINT) -s3-access-key-id $(MINIO_USER_ACCESS_KEY) -s3-secret-access-key $(MINIO_USER_SECRET_KEY)
Expand Down
9 changes: 9 additions & 0 deletions pkg/testutils/testconfig/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (

flagManagedCluster = flag.String("managed-cluster", "127.0.0.1", "a comma-separated list of host:port tuples of data cluster hosts")
flagManagedSecondCluster = flag.String("managed-second-cluster", "127.0.0.1", "a comma-separated list of host:port tuples of data second cluster hosts")
flagManagedThirdCluster = flag.String("managed-third-cluster", "127.0.0.1", "a comma-separated list of host:port tuples of data third cluster hosts")
flagTestNet = flag.String("test-network", "192.168.200.", "a network where test nodes are residing")
)

Expand Down Expand Up @@ -69,6 +70,14 @@ func ManagedSecondClusterHosts() []string {
return strings.Split(*flagManagedSecondCluster, ",")
}

// ManagedThirdClusterHosts specifies addresses of nodes in a test second cluster.
func ManagedThirdClusterHosts() []string {
if !flag.Parsed() {
flag.Parse()
}
return strings.Split(*flagManagedThirdCluster, ",")
}

// ManagedClusterCredentials returns CQL username and password.
func ManagedClusterCredentials() (user, password string) {
if !flag.Parsed() {
Expand Down
15 changes: 12 additions & 3 deletions testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CQLSH := $(COMPOSE) exec scylla-manager-db cqlsh
CQLSH_NODE := $(COMPOSE) exec -T dc1_node_1 cqlsh
NODETOOL := $(COMPOSE) exec -T dc1_node_1 nodetool
SECOND_NODETOOL := $(COMPOSE) exec -T second_cluster_dc1_node_1 nodetool
THIRD_NODETOOL := $(COMPOSE) exec -T third_cluster_dc3_node_1 nodetool
SM_NODETOOL := $(COMPOSE) exec -T scylla-manager-db nodetool
YQ := ../bin/yq
CURRENT_UID := $(shell id -u)
Expand Down Expand Up @@ -33,9 +34,11 @@ endif

SCYLLA_ARGS := --smp 2 --memory 2G --seeds $(SECOND_NET)11
SCYLLA_SECOND_CLUSTER_ARGS := --smp 2 --memory 2G --seeds $(SECOND_NET)31
SCYLLA_THIRD_CLUSTER_ARGS := --smp 1 --memory 2G --seeds $(SECOND_NET)41

export SCYLLA_ARGS
export SCYLLA_SECOND_CLUSTER_ARGS
export SCYLLA_THIRD_CLUSTER_ARGS
export MINIO_ENDPOINT
export MINIO_CERT_DIR

Expand Down Expand Up @@ -66,7 +69,7 @@ up:

ifeq ($(SSL_ENABLED),true)
# disable non-ssl port
@$(YQ) delete -i scylla/scylla.yaml 'native_transport_port'
# @$(YQ) delete -i scylla/scylla.yaml 'native_transport_port'
# merge into scylla.yaml values from config/scylla-ssl.yaml with overwrite option (-x)
@$(YQ) merge -i -x scylla/scylla.yaml scylla/config/scylla-ssl.yaml
@cp scylla/config/cqlshrc-ssl scylla/cqlshrc
Expand All @@ -89,10 +92,13 @@ endif
@cp scylla/scylla.yaml scylla/scylla-second-cluster.yaml
@$(YQ) write -i scylla/scylla-second-cluster.yaml 'cluster_name' 'Managed Other Cluster'

@cp scylla/scylla.yaml scylla/scylla-third-cluster.yaml
@$(YQ) write -i scylla/scylla-third-cluster.yaml 'cluster_name' 'Managed Third Cluster'

@echo "==> Starting containers"
mkdir -p $(MINIO_DATA_DIR)

@. ./.env && CURRENT_UID=$(CURRENT_UID) CURRENT_GID=$(CURRENT_GID) $(COMPOSE) -f docker-compose.yaml -f $(COMPOSE_FILE) up -d dc1_node_1 second_cluster_dc1_node_1
@. ./.env && CURRENT_UID=$(CURRENT_UID) CURRENT_GID=$(CURRENT_GID) $(COMPOSE) -f docker-compose.yaml -f $(COMPOSE_FILE) up -d dc1_node_1 second_cluster_dc1_node_1 third_cluster_dc3_node_1
$(COMPOSE) exec -T --privileged dc1_node_1 sudo bash -c 'echo "fs.aio-max-nr = 1048579" > /etc/sysctl.d/50-scylla.conf'
$(COMPOSE) exec -T --privileged dc1_node_1 sudo sysctl -p /etc/sysctl.d/50-scylla.conf
@echo "==> Waiting for dc1 node1"
Expand All @@ -104,13 +110,16 @@ endif
@until [ 1 -le $$($(SECOND_NODETOOL) status | grep -c "UN") ]; do echo -n "."; sleep 2; done ; echo ""
@. ./.env && CURRENT_UID=$(CURRENT_UID) CURRENT_GID=$(CURRENT_GID) $(COMPOSE) -f docker-compose.yaml -f $(COMPOSE_FILE) up -d second_cluster_dc1_node_2

@until [ 1 -le $$($(THIRD_NODETOOL) status | grep -c "UN") ]; do echo -n "."; sleep 2; done ; echo ""
@. ./.env && CURRENT_UID=$(CURRENT_UID) CURRENT_GID=$(CURRENT_GID) $(COMPOSE) -f docker-compose.yaml -f $(COMPOSE_FILE) up -d third_cluster_dc3_node_2

@cnt=1; for node in dc1_node_2 dc1_node_3 dc2_node_1 dc2_node_2 dc2_node_3; do \
. ./.env && CURRENT_UID=$(CURRENT_UID) CURRENT_GID=$(CURRENT_GID) $(COMPOSE) -f docker-compose.yaml -f $(COMPOSE_FILE) up -d $$node; \
cnt=$$(expr $$cnt + 1); \
echo "==> Waiting node $$node number $$cnt"; \
until [ $$cnt -le $$($(NODETOOL) status | grep -c "UN") ]; do echo -n "."; sleep 2; done ; echo ""; done

@for node in dc1_node_1 dc1_node_2 dc1_node_3 dc2_node_1 dc2_node_2 dc2_node_3 second_cluster_dc1_node_1 second_cluster_dc1_node_2; do \
@for node in dc1_node_1 dc1_node_2 dc1_node_3 dc2_node_1 dc2_node_2 dc2_node_3 second_cluster_dc1_node_1 second_cluster_dc1_node_2 third_cluster_dc3_node_1 third_cluster_dc3_node_2; do \
$(COMPOSE) exec -T --privileged $$node sudo bash -c 'service ssh start'; done

@. ./.env && CURRENT_UID=$(CURRENT_UID) CURRENT_GID=$(CURRENT_GID) $(COMPOSE) -f docker-compose.yaml -f $(COMPOSE_FILE) up -d
Expand Down
16 changes: 16 additions & 0 deletions testing/docker-compose-ipv4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ services:
second:
ipv4_address: 192.168.200.32

third_cluster_dc3_node_1:
command: ${SCYLLA_THIRD_CLUSTER_ARGS} --rpc-address 192.168.100.41 --alternator-address 192.168.200.41 --listen-address 192.168.200.41
networks:
public:
ipv4_address: 192.168.100.41
second:
ipv4_address: 192.168.200.41

third_cluster_dc3_node_2:
command: ${SCYLLA_THIRD_CLUSTER_ARGS} --rpc-address 192.168.100.42 --alternator-address 192.168.200.42 --listen-address 192.168.200.42
networks:
public:
ipv4_address: 192.168.100.42
second:
ipv4_address: 192.168.200.42

scylla-manager-db:
command: --smp 1 --memory 500M --api-address 0.0.0.0 --seeds 192.168.200.100 --rpc-address 192.168.200.100 --alternator-address 192.168.200.100 --listen-address 192.168.200.100
networks:
Expand Down
16 changes: 16 additions & 0 deletions testing/docker-compose-ipv6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ services:
second:
ipv6_address: 2001:0DB9:200::32

third_cluster_dc3_node_1:
command: ${SCYLLA_THIRD_CLUSTER_ARGS} --rpc-address 2001:0DB9:100::41 --alternator-address 2001:0DB9:200::41 --listen-address 2001:0DB9:200::41
networks:
public:
ipv6_address: 2001:0DB9:100::41
third:
ipv6_address: 2001:0DB9:200::41

third_cluster_dc3_node_2:
command: ${SCYLLA_THIRD_CLUSTER_ARGS} --rpc-address 2001:0DB9:100::42 --alternator-address 2001:0DB9:200::42 --listen-address 2001:0DB9:200::42
networks:
public:
ipv6_address: 2001:0DB9:100::42
third:
ipv6_address: 2001:0DB9:200::42

scylla-manager-db:
command: --smp 1 --memory 500M --api-address 0.0.0.0 --seeds 2001:0DB9:200::100 --rpc-address 2001:0DB9:200::100 --alternator-address 2001:0DB9:200::100 --listen-address 2001:0DB9:200::100
networks:
Expand Down
38 changes: 38 additions & 0 deletions testing/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,40 @@ services:
public:
second:

third_cluster_dc3_node_1:
image: scylladb/agent-${SCYLLA_VERSION}
privileged: true
volumes:
- type: bind
source: ./scylla/cassandra-rackdc.3.properties
target: /etc/scylla/cassandra-rackdc.properties
- type: bind
source: ./scylla/scylla-third-cluster.yaml
target: /etc/scylla/scylla.yaml
- type: bind
source: ./scylla/certs/
target: /etc/scylla/certs
networks:
public:
third:

third_cluster_dc3_node_2:
image: scylladb/agent-${SCYLLA_VERSION}
privileged: true
volumes:
- type: bind
source: ./scylla/cassandra-rackdc.3.properties
target: /etc/scylla/cassandra-rackdc.properties
- type: bind
source: ./scylla/scylla-third-cluster.yaml
target: /etc/scylla/scylla.yaml
- type: bind
source: ./scylla/certs/
target: /etc/scylla/certs
networks:
public:
third:

scylla-manager-db:
image: scylladb/${SCYLLA_VERSION}
ports:
Expand Down Expand Up @@ -188,3 +222,7 @@ networks:
driver: bridge
ipam:
driver: default
third:
driver: bridge
ipam:
driver: default
2 changes: 1 addition & 1 deletion testing/nodes_cp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ set -eu -o pipefail
declare -r SRC_PATH=$1
declare -r DEST_PATH=$2

for name in $(docker ps -f name=dc1_node -f name=dc2_node --format {{.Names}}); do
for name in $(docker ps -f name=dc1_node -f name=dc2_node -f name=dc3_node --format {{.Names}}); do
docker cp ${SRC_PATH} ${name}:${DEST_PATH}
done
4 changes: 2 additions & 2 deletions testing/nodes_exec
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ case "$1" in
;;
esac

for name in $(docker ps -f name=dc1_node -f name=dc2_node --format {{.Names}}); do
for name in $(docker ps -f name=dc1_node -f name=dc2_node -f name=dc3_node --format {{.Names}}); do
if [[ ${SILENT} == 1 ]]; then
docker exec ${name} bash -c "$*" > /dev/null
else
echo "> ${name}"
docker exec ${name} bash -c "$*"
fi
done
done
3 changes: 3 additions & 0 deletions testing/scylla/cassandra-rackdc.3.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dc=dc3
rack=rack1
prefer_local=true
2 changes: 1 addition & 1 deletion testing/scylla/config/scylla.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -647,4 +647,4 @@ alternator_write_isolation: only_rmw_uses_lwt
alternator_enforce_authorization: true
enable_ipv6_dns_lookup: true

uuid_sstable_identifiers_enabled: false
uuid_sstable_identifiers_enabled: false
Loading