Skip to content

Commit

Permalink
docker compose, drop --compatibility flag
Browse files Browse the repository at this point in the history
The compatibility flag affects what word separator is used in the
container name.

> Compose generates container names based on the project name, service name, and scale/replica count.
> In Compose V1, an underscore (_) was used as the word separator. In Compose V2, a hyphen (-) is used as the word separator.

We don't usually rely on specific container names, so this should be
fine.
In some exception cases where this seems more practical (containers for
bazel-remote-cache and go-module-proxy) due to special casing in the CI
scripts, container_name is set explicitly.
  • Loading branch information
matzf committed Oct 31, 2023
1 parent d0faa46 commit 433a03a
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 36 deletions.
1 change: 1 addition & 0 deletions .buildkite/hooks/go-module-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: "2.4"
name: athens
services:
go-module-proxy:
container_name: go-module-proxy
network_mode: host
# gomods/athens:canary of 29.04.2022 -- using unstable version for the "ATHENS_NETWORK_MODE=offline" feature, see below
image: $REGISTRY/gomods/athens@sha256:319701a7541a3e70ff45f290b185364738cac62b845eeb13b25c258f6189af7f
Expand Down
4 changes: 2 additions & 2 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ echo "~~~ Starting bazel remote cache proxy"
# Start bazel remote cache proxy for S3
# Note that S3 keys are injected by buildkite, see
# https://buildkite.com/docs/pipelines/secrets#storing-secrets-with-the-elastic-ci-stack-for-aws
docker compose --compatibility -f .buildkite/hooks/bazel-remote.yml up -d
docker compose -f .buildkite/hooks/bazel-remote.yml up -d

echo "~~~ Starting go module proxy"
docker compose --compatibility -f .buildkite/hooks/go-module-proxy.yml up -d
docker compose -f .buildkite/hooks/go-module-proxy.yml up -d
2 changes: 1 addition & 1 deletion acceptance/common/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __call__(self, *args, **kwargs) -> str:
# Note: not using plumbum here due to complications with encodings in the captured output
try:
res = subprocess.run(
["docker", "compose", "--compatibility", "-f", self.compose_file, *args],
["docker", "compose", "-f", self.compose_file, *args],
check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8")
except subprocess.CalledProcessError as e:
raise _CalledProcessErrorWithOutput(e) from None
Expand Down
14 changes: 7 additions & 7 deletions acceptance/sig_short_exp_time/test
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ run_test() {(set -e
docker image load -i acceptance/sig_short_exp_time/sig1.tar
docker image load -i acceptance/sig_short_exp_time/sig2.tar

docker compose --compatibility -f acceptance/sig_short_exp_time/docker-compose.yml up -d dispatcher1 dispatcher2 sig1 sig2 patha pathb
docker compose -f acceptance/sig_short_exp_time/docker-compose.yml up -d dispatcher1 dispatcher2 sig1 sig2 patha pathb

# Set up forward route on network stack 1 and 2 through the sig tunnel
# device. The route is a property of the network stack, and persists after
# the container that added it has exited.
#
# If the route configuration fails, the test is not stopped.
docker compose --compatibility -f acceptance/sig_short_exp_time/docker-compose.yml run --name route1 --rm tester1 ip route add 242.254.200.2/32 dev sig || true
docker compose --compatibility -f acceptance/sig_short_exp_time/docker-compose.yml run --name route2 --rm tester2 ip route add 242.254.100.2/32 dev sig || true
docker compose -f acceptance/sig_short_exp_time/docker-compose.yml run --name route1 --rm tester1 ip route add 242.254.200.2/32 dev sig || true
docker compose -f acceptance/sig_short_exp_time/docker-compose.yml run --name route2 --rm tester2 ip route add 242.254.100.2/32 dev sig || true

echo "Start background ping, ping every 0.2 seconds"
docker compose --compatibility -f acceptance/sig_short_exp_time/docker-compose.yml run --name tester1 -d tester1 ping -i 0.2 242.254.200.2
docker compose -f acceptance/sig_short_exp_time/docker-compose.yml run --name tester1 -d tester1 ping -i 0.2 242.254.200.2

echo "Waiting 10 seconds for path A to expire..."
sleep 10
echo "Path A expired, simulating it by shutting down path A proxy"
# Traffic should have switched beforehand to path b, and no pings should be lost
docker compose --compatibility -f acceptance/sig_short_exp_time/docker-compose.yml stop patha
docker compose -f acceptance/sig_short_exp_time/docker-compose.yml stop patha
sleep 1
docker kill -s SIGINT tester1

Expand Down Expand Up @@ -104,9 +104,9 @@ OUTPUT_DIR=$TEST_UNDECLARED_OUTPUTS_DIR
mkdir -p $OUTPUT_DIR/logs

for CNTR in sig1 sig2 dispatcher1 dispatcher2; do
docker compose --compatibility -f acceptance/sig_short_exp_time/docker-compose.yml logs "$CNTR" > "$OUTPUT_DIR/logs/$CNTR.log"
docker compose -f acceptance/sig_short_exp_time/docker-compose.yml logs "$CNTR" > "$OUTPUT_DIR/logs/$CNTR.log"
done

docker compose --compatibility -f acceptance/sig_short_exp_time/docker-compose.yml down -v
docker compose -f acceptance/sig_short_exp_time/docker-compose.yml down -v

exit $RC
2 changes: 0 additions & 2 deletions acceptance/topo_cs_reload/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ networks:
- subnet: 242.253.100.0/24
services:
topo_cs_reload_dispatcher:
container_name: topo_cs_reload_dispatcher
image: bazel/acceptance/topo_cs_reload:dispatcher
networks:
bridge1:
ipv4_address: 242.253.100.2
volumes:
- vol_topo_cs_reload_disp:/run/shm/dispatcher:rw
topo_cs_reload_control_srv:
container_name: topo_cs_reload_control_srv
image: bazel/acceptance/topo_cs_reload:control
depends_on:
- topo_cs_reload_dispatcher
Expand Down
18 changes: 7 additions & 11 deletions acceptance/topo_cs_reload/reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,23 @@ func setupTest(t *testing.T) testState {
require.NoError(t, err)
topoFile, err := bazel.Runfile(*topoLocation)
require.NoError(t, err)
s.mustExec(t, *genCryptoLocation, scionPKI,
"crypto.tar", topoFile, cryptoLib)
s.mustExec(t, *genCryptoLocation, scionPKI, "crypto.tar", topoFile, cryptoLib)
s.mustExec(t, "tar", "-xf", "crypto.tar", "-C", tmpDir)
// first load the docker images from bazel into the docker deamon, the
// tars are in the same folder as this test runs in bazel.
s.mustExec(t, "docker", "image", "load", "-i", "dispatcher.tar")
s.mustExec(t, "docker", "image", "load", "-i", "control.tar")
// now start the docker containers
s.mustExec(t, "docker", "compose", "--compatibility", "-f", "docker-compose.yml",
"up", "-d")
s.mustExec(t, "docker", "compose", "-f", "docker-compose.yml", "up", "-d")
// wait a bit to make sure the containers are ready.
time.Sleep(time.Second / 2)
t.Log("Test setup done")
s.mustExec(t, "docker", "compose", "--compatibility", "-f", "docker-compose.yml",
"ps")
s.mustExec(t, "docker", "compose", "-f", "docker-compose.yml", "ps")
return s
}

func (s testState) teardownTest(t *testing.T) {
defer s.mustExec(t, "docker", "compose", "--compatibility",
"-f", "docker-compose.yml", "down", "-v")
defer s.mustExec(t, "docker", "compose", "-f", "docker-compose.yml", "down", "-v")

outdir, exists := os.LookupEnv("TEST_UNDECLARED_OUTPUTS_DIR")
require.True(t, exists, "TEST_UNDECLARED_OUTPUTS_DIR must be defined")
Expand All @@ -130,7 +126,7 @@ func (s testState) teardownTest(t *testing.T) {
"topo_cs_reload_dispatcher": "disp.log",
"topo_cs_reload_control_srv": "control.log",
} {
cmd := exec.Command("docker", "compose", "--compatibility",
cmd := exec.Command("docker", "compose",
"-f", "docker-compose.yml", "logs", "--no-color", service)
logFileName := fmt.Sprintf("%s/logs/%s", outdir, file)
logFile, err := os.Create(logFileName)
Expand All @@ -149,9 +145,9 @@ func (s testState) teardownTest(t *testing.T) {
func (s testState) loadTopo(t *testing.T, name string) {
t.Helper()

s.mustExec(t, "docker", "compose", "--compatibility", "-f", "docker-compose.yml",
s.mustExec(t, "docker", "compose", "-f", "docker-compose.yml",
"exec", "-T", "topo_cs_reload_control_srv", "mv", name, "/topology.json")
s.mustExec(t, "docker", "compose", "--compatibility", "-f", "docker-compose.yml",
s.mustExec(t, "docker", "compose", "-f", "docker-compose.yml",
"kill", "-s", "SIGHUP", "topo_cs_reload_control_srv")
}

Expand Down
13 changes: 6 additions & 7 deletions acceptance/topo_daemon_reload/reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,17 @@ func setupTest(t *testing.T) {
mustExec(t, "docker", "image", "load", "-i", "dispatcher.tar")
mustExec(t, "docker", "image", "load", "-i", "daemon.tar")
// now start the docker containers
mustExec(t, "docker", "compose", "--compatibility", "-f", "docker-compose.yml",
mustExec(t, "docker", "compose", "-f", "docker-compose.yml",
"up", "-d", "topo_daemon_reload_dispatcher", "topo_daemon_reload_daemon")
// wait a bit to make sure the containers are ready.
time.Sleep(time.Second / 2)
t.Log("Test setup done")
mustExec(t, "docker", "compose", "--compatibility", "-f", "docker-compose.yml",
mustExec(t, "docker", "compose", "-f", "docker-compose.yml",
"ps")
}

func teardownTest(t *testing.T) {
defer mustExec(t, "docker", "compose", "--compatibility",
"-f", "docker-compose.yml", "down", "-v")
defer mustExec(t, "docker", "compose", "-f", "docker-compose.yml", "down", "-v")

outdir, exists := os.LookupEnv("TEST_UNDECLARED_OUTPUTS_DIR")
require.True(t, exists, "TEST_UNDECLARED_OUTPUTS_DIR must be defined")
Expand All @@ -92,7 +91,7 @@ func teardownTest(t *testing.T) {
"topo_daemon_reload_dispatcher": "disp.log",
"topo_daemon_reload_daemon": "daemon.log",
} {
cmd := exec.Command("docker", "compose", "--compatibility",
cmd := exec.Command("docker", "compose",
"-f", "docker-compose.yml", "logs", "--no-color",
service)
logFileName := fmt.Sprintf("%s/logs/%s", outdir, file)
Expand All @@ -111,9 +110,9 @@ func teardownTest(t *testing.T) {
func loadTopo(t *testing.T, name string) {
t.Helper()

mustExec(t, "docker", "compose", "--compatibility", "-f", "docker-compose.yml",
mustExec(t, "docker", "compose", "-f", "docker-compose.yml",
"exec", "-T", "topo_daemon_reload_daemon", "mv", name, "/topology.json")
mustExec(t, "docker", "compose", "--compatibility", "-f", "docker-compose.yml",
mustExec(t, "docker", "compose", "-f", "docker-compose.yml",
"kill", "-s", "SIGHUP", "topo_daemon_reload_daemon")
}

Expand Down
4 changes: 2 additions & 2 deletions scion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmd_bazel-remote() {
mkdir -p "$HOME/.cache/bazel/remote"
uid=$(id -u)
gid=$(id -g)
USER_ID="$uid" GROUP_ID="$gid" docker compose --compatibility -f bazel-remote.yml up -d
USER_ID="$uid" GROUP_ID="$gid" docker compose -f bazel-remote.yml up -d
}

cmd_topo-clean() {
Expand Down Expand Up @@ -36,7 +36,7 @@ cmd_topodot() {
start_scion() {
echo "Running the network..."
if is_docker_be; then
docker compose --compatibility -f gen/scion-dc.yml up -d
docker compose -f gen/scion-dc.yml up -d
return 0
else
run_setup
Expand Down
2 changes: 1 addition & 1 deletion tools/dc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ cmd_monitoring() {
dc() {
local dc_file="gen/$1-dc.yml"
shift
COMPOSE_FILE="$dc_file" docker compose --compatibility --ansi never "$@"
COMPOSE_FILE="$dc_file" docker compose --ansi never "$@"
}

cmd_collect_logs() {
Expand Down
5 changes: 2 additions & 3 deletions tools/integration/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ var (
var dockerArgs []string

func initDockerArgs() {
dockerArgs = []string{"compose", "--compatibility",
"-f", GenFile("scion-dc.yml"), "exec", "-T", "-e",
fmt.Sprintf("%s=1", GoIntegrationEnv)}
dockerArgs = []string{"compose", "-f", GenFile("scion-dc.yml"), "exec", "-T",
"-e", fmt.Sprintf("%s=1", GoIntegrationEnv)}
}

var _ Integration = (*dockerIntegration)(nil)
Expand Down

0 comments on commit 433a03a

Please sign in to comment.