-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document socket-proxy permissions, return early when update failed on…
… scaling down (#343) * Do not await containers when there was an error on scaling * Add test case for usage with socket proxy * Add documentation on required permissions for docker-socket-proxy * Add full list of used Docker APIs to doc * CONTAINER_START and CONTAINER_STOP is not needed
- Loading branch information
Showing
5 changed files
with
183 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2020-2021 - Offen Authors <[email protected]> | ||
# SPDX-License-Identifier: Unlicense | ||
|
||
version: '3.8' | ||
|
||
services: | ||
backup: | ||
image: offen/docker-volume-backup:${TEST_VERSION:-canary} | ||
environment: | ||
BACKUP_FILENAME: test.tar.gz | ||
BACKUP_CRON_EXPRESSION: 0 0 5 31 2 ? | ||
DOCKER_HOST: tcp://docker_socket_proxy:2375 | ||
volumes: | ||
- pg_data:/backup/pg_data:ro | ||
- ${LOCAL_DIR:-local}:/archive | ||
|
||
docker_socket_proxy: | ||
image: tecnativa/docker-socket-proxy:0.1 | ||
environment: | ||
INFO: ${ALLOW_INFO:-1} | ||
CONTAINERS: ${ALLOW_CONTAINERS:-1} | ||
SERVICES: ${ALLOW_SERVICES:-1} | ||
POST: ${ALLOW_POST:-1} | ||
TASKS: ${ALLOW_TASKS:-1} | ||
NODES: ${ALLOW_NODES:-1} | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
|
||
pg: | ||
image: postgres:14-alpine | ||
environment: | ||
POSTGRES_PASSWORD: example | ||
volumes: | ||
- pg_data:/var/lib/postgresql/data | ||
deploy: | ||
labels: | ||
- docker-volume-backup.stop-during-backup=true | ||
|
||
volumes: | ||
pg_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2020-2021 - Offen Authors <[email protected]> | ||
# SPDX-License-Identifier: Unlicense | ||
|
||
version: '3.8' | ||
|
||
services: | ||
backup: | ||
image: offen/docker-volume-backup:${TEST_VERSION:-canary} | ||
environment: | ||
BACKUP_FILENAME: test.tar.gz | ||
BACKUP_CRON_EXPRESSION: 0 0 5 31 2 ? | ||
DOCKER_HOST: tcp://docker_socket_proxy:2375 | ||
volumes: | ||
- pg_data:/backup/pg_data:ro | ||
- ${LOCAL_DIR:-local}:/archive | ||
|
||
docker_socket_proxy: | ||
image: tecnativa/docker-socket-proxy:0.1 | ||
environment: | ||
INFO: ${ALLOW_INFO:-1} | ||
CONTAINERS: ${ALLOW_CONTAINERS:-1} | ||
POST: ${ALLOW_POST:-1} | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
|
||
pg: | ||
image: postgres:14-alpine | ||
environment: | ||
POSTGRES_PASSWORD: example | ||
volumes: | ||
- pg_data:/var/lib/postgresql/data | ||
labels: | ||
- docker-volume-backup.stop-during-backup=true | ||
|
||
volumes: | ||
pg_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
cd $(dirname $0) | ||
. ../util.sh | ||
current_test=$(basename $(pwd)) | ||
|
||
export LOCAL_DIR=$(mktemp -d) | ||
|
||
docker compose up -d --quiet-pull | ||
sleep 5 | ||
|
||
# The default configuration in docker-compose.yml should | ||
# successfully create a backup. | ||
docker compose exec backup backup | ||
|
||
sleep 5 | ||
|
||
expect_running_containers "3" | ||
|
||
if [ ! -f "$LOCAL_DIR/test.tar.gz" ]; then | ||
fail "Archive was not created" | ||
fi | ||
pass "Found relevant archive file." | ||
|
||
# Disabling POST should make the backup run fail | ||
ALLOW_POST="0" docker compose up -d | ||
sleep 5 | ||
|
||
set +e | ||
docker compose exec backup backup | ||
if [ $? = "0" ]; then | ||
fail "Expected invocation to exit non-zero." | ||
fi | ||
set -e | ||
pass "Invocation exited non-zero." | ||
|
||
docker compose down --volumes | ||
|
||
# Next, the test is run against a Swarm setup | ||
|
||
docker swarm init | ||
|
||
export LOCAL_DIR=$(mktemp -d) | ||
|
||
docker stack deploy --compose-file=docker-compose.swarm.yml test_stack | ||
|
||
sleep 20 | ||
|
||
# The default configuration in docker-compose.swarm.yml should | ||
# successfully create a backup in Swarm mode. | ||
docker exec $(docker ps -q -f name=backup) backup | ||
|
||
if [ ! -f "$LOCAL_DIR/test.tar.gz" ]; then | ||
fail "Archive was not created" | ||
fi | ||
|
||
pass "Found relevant archive file." | ||
|
||
sleep 5 | ||
expect_running_containers "3" | ||
|
||
# Disabling POST should make the backup run fail | ||
ALLOW_POST="0" docker stack deploy --compose-file=docker-compose.swarm.yml test_stack | ||
|
||
sleep 20 | ||
|
||
set +e | ||
docker exec $(docker ps -q -f name=backup) backup | ||
if [ $? = "0" ]; then | ||
fail "Expected invocation to exit non-zero." | ||
fi | ||
set -e | ||
|
||
pass "Invocation exited non-zero." |