From 9aab3d628c688fd595fb60af581d1c72d7dd92d1 Mon Sep 17 00:00:00 2001 From: Martin Angers Date: Wed, 12 Apr 2023 15:14:28 -0400 Subject: [PATCH] Move Redis cluster docker yml to separate file (#11162) --- .github/workflows/test-go.yaml | 2 +- docker-compose-redis-cluster.yml | 89 +++++++++++++++++++ docker-compose.yml | 87 ------------------ .../Testing-and-local-development.md | 8 ++ server/service/appconfig.go | 4 +- 5 files changed, 100 insertions(+), 90 deletions(-) create mode 100644 docker-compose-redis-cluster.yml diff --git a/.github/workflows/test-go.yaml b/.github/workflows/test-go.yaml index 4ce3e115b..c0a14360d 100644 --- a/.github/workflows/test-go.yaml +++ b/.github/workflows/test-go.yaml @@ -60,7 +60,7 @@ jobs: # Pre-starting dependencies here means they are ready to go when we need them. - name: Start Infra Dependencies # Use & to background this - run: FLEET_MYSQL_IMAGE=${{ matrix.mysql }} docker-compose up -d mysql_test redis redis-cluster-1 redis-cluster-2 redis-cluster-3 redis-cluster-4 redis-cluster-5 redis-cluster-6 redis-cluster-setup minio saml_idp mailhog mailpit & + run: FLEET_MYSQL_IMAGE=${{ matrix.mysql }} docker-compose -f docker-compose.yml -f docker-compose-redis-cluster.yml up -d mysql_test redis redis-cluster-1 redis-cluster-2 redis-cluster-3 redis-cluster-4 redis-cluster-5 redis-cluster-6 redis-cluster-setup minio saml_idp mailhog mailpit & # It seems faster not to cache Go dependencies - name: Install Go Dependencies diff --git a/docker-compose-redis-cluster.yml b/docker-compose-redis-cluster.yml new file mode 100644 index 000000000..394223e2d --- /dev/null +++ b/docker-compose-redis-cluster.yml @@ -0,0 +1,89 @@ +--- +version: "2" +services: + redis-cluster-setup: + image: redis:5 + command: redis-cli --cluster create 172.20.0.31:7001 172.20.0.32:7002 172.20.0.33:7003 172.20.0.34:7004 172.20.0.35:7005 172.20.0.36:7006 --cluster-yes --cluster-replicas 1 + networks: + cluster_network: + ipv4_address: 172.20.0.30 + depends_on: + - redis-cluster-1 + - redis-cluster-2 + - redis-cluster-3 + - redis-cluster-4 + - redis-cluster-5 + - redis-cluster-6 + + redis-cluster-1: + image: redis:5 + command: redis-server /usr/local/etc/redis/redis.conf + ports: + - "7001:7001" + volumes: + - ./tools/redis-tests/redis-cluster-1.conf:/usr/local/etc/redis/redis.conf + networks: + cluster_network: + ipv4_address: 172.20.0.31 + + redis-cluster-2: + image: redis:5 + command: redis-server /usr/local/etc/redis/redis.conf + ports: + - "7002:7002" + volumes: + - ./tools/redis-tests/redis-cluster-2.conf:/usr/local/etc/redis/redis.conf + networks: + cluster_network: + ipv4_address: 172.20.0.32 + + redis-cluster-3: + image: redis:5 + command: redis-server /usr/local/etc/redis/redis.conf + ports: + - "7003:7003" + volumes: + - ./tools/redis-tests/redis-cluster-3.conf:/usr/local/etc/redis/redis.conf + networks: + cluster_network: + ipv4_address: 172.20.0.33 + + redis-cluster-4: + image: redis:5 + command: redis-server /usr/local/etc/redis/redis.conf + ports: + - "7004:7004" + volumes: + - ./tools/redis-tests/redis-cluster-4.conf:/usr/local/etc/redis/redis.conf + networks: + cluster_network: + ipv4_address: 172.20.0.34 + + redis-cluster-5: + image: redis:5 + command: redis-server /usr/local/etc/redis/redis.conf + ports: + - "7005:7005" + volumes: + - ./tools/redis-tests/redis-cluster-5.conf:/usr/local/etc/redis/redis.conf + networks: + cluster_network: + ipv4_address: 172.20.0.35 + + redis-cluster-6: + image: redis:5 + command: redis-server /usr/local/etc/redis/redis.conf + ports: + - "7006:7006" + volumes: + - ./tools/redis-tests/redis-cluster-6.conf:/usr/local/etc/redis/redis.conf + networks: + cluster_network: + ipv4_address: 172.20.0.36 + +networks: + cluster_network: + driver: bridge + ipam: + config: + - subnet: 172.20.0.0/24 diff --git a/docker-compose.yml b/docker-compose.yml index f038b60a1..7268b9f40 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -81,86 +81,6 @@ services: ports: - "6379:6379" - redis-cluster-setup: - image: redis:5 - command: redis-cli --cluster create 172.20.0.31:7001 172.20.0.32:7002 172.20.0.33:7003 172.20.0.34:7004 172.20.0.35:7005 172.20.0.36:7006 --cluster-yes --cluster-replicas 1 - networks: - cluster_network: - ipv4_address: 172.20.0.30 - depends_on: - - redis-cluster-1 - - redis-cluster-2 - - redis-cluster-3 - - redis-cluster-4 - - redis-cluster-5 - - redis-cluster-6 - - redis-cluster-1: - image: redis:5 - command: redis-server /usr/local/etc/redis/redis.conf - ports: - - "7001:7001" - volumes: - - ./tools/redis-tests/redis-cluster-1.conf:/usr/local/etc/redis/redis.conf - networks: - cluster_network: - ipv4_address: 172.20.0.31 - - redis-cluster-2: - image: redis:5 - command: redis-server /usr/local/etc/redis/redis.conf - ports: - - "7002:7002" - volumes: - - ./tools/redis-tests/redis-cluster-2.conf:/usr/local/etc/redis/redis.conf - networks: - cluster_network: - ipv4_address: 172.20.0.32 - - redis-cluster-3: - image: redis:5 - command: redis-server /usr/local/etc/redis/redis.conf - ports: - - "7003:7003" - volumes: - - ./tools/redis-tests/redis-cluster-3.conf:/usr/local/etc/redis/redis.conf - networks: - cluster_network: - ipv4_address: 172.20.0.33 - - redis-cluster-4: - image: redis:5 - command: redis-server /usr/local/etc/redis/redis.conf - ports: - - "7004:7004" - volumes: - - ./tools/redis-tests/redis-cluster-4.conf:/usr/local/etc/redis/redis.conf - networks: - cluster_network: - ipv4_address: 172.20.0.34 - - redis-cluster-5: - image: redis:5 - command: redis-server /usr/local/etc/redis/redis.conf - ports: - - "7005:7005" - volumes: - - ./tools/redis-tests/redis-cluster-5.conf:/usr/local/etc/redis/redis.conf - networks: - cluster_network: - ipv4_address: 172.20.0.35 - - redis-cluster-6: - image: redis:5 - command: redis-server /usr/local/etc/redis/redis.conf - ports: - - "7006:7006" - volumes: - - ./tools/redis-tests/redis-cluster-6.conf:/usr/local/etc/redis/redis.conf - networks: - cluster_network: - ipv4_address: 172.20.0.36 - saml_idp: image: fleetdm/docker-idp:latest environment: @@ -223,10 +143,3 @@ volumes: mysql-persistent-volume: data-minio: - -networks: - cluster_network: - driver: bridge - ipam: - config: - - subnet: 172.20.0.0/24 diff --git a/docs/Contributing/Testing-and-local-development.md b/docs/Contributing/Testing-and-local-development.md index 04e3ac375..37f87b04b 100644 --- a/docs/Contributing/Testing-and-local-development.md +++ b/docs/Contributing/Testing-and-local-development.md @@ -71,6 +71,14 @@ Make sure it is available in your `PATH`. To execute the basic unit and integrat REDIS_TEST=1 MYSQL_TEST=1 make test ``` +Note that on a Linux system, the Redis tests will include running in cluster mode, so the docker Redis Cluster setup must be running. This implies starting the docker dependencies as follows: + +``` +# start both the default docker-compose.yml and the redis cluster-specific +# docker-compose-redis-cluster.yml +$ docker-compose -f docker-compose.yml -f docker-compose-redis-cluster.yml up +``` + ### Go unit tests To run all Go unit tests, run the following: diff --git a/server/service/appconfig.go b/server/service/appconfig.go index b58327cf7..87dd95de0 100644 --- a/server/service/appconfig.go +++ b/server/service/appconfig.go @@ -24,9 +24,9 @@ import ( "github.com/kolide/kit/version" ) -// ////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Get AppConfig -// ////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// type appConfigResponse struct { fleet.AppConfig