Skip to content

Commit

Permalink
Increase timeouts and add healthchecks
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger committed Sep 19, 2023
1 parent d3c4a16 commit a53f3bc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion hole-punch-interop/impl/rust/v0.52/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
image_name := rust-v0.52
commitSha := bb251a4f88d44a64447f1c66b8a7918cfaea9afb
commitSha := 919f49e8374bbe1a24654aac56414f2e83aa5484

all: image.json

Expand Down
2 changes: 2 additions & 0 deletions hole-punch-interop/router/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ RUN --mount=type=cache,target=/var/cache/apt apt-get update && apt-get -y instal
COPY *.sh /scripts/
RUN chmod +x /scripts/*.sh

HEALTHCHECK CMD [ "sh", "-c", "test $(cat /var/setup_done) = 1" ]

ENTRYPOINT ["./scripts/run.sh"]
6 changes: 4 additions & 2 deletions hole-punch-interop/router/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ nft add table ip nat
nft add chain ip nat postrouting { type nat hook postrouting priority 100 \; }
nft add rule ip nat postrouting ip saddr $SUBNET_INTERNAL oifname "eth1" snat $ADDR_EXTERNAL

tc qdisc add dev eth0 root netem delay 30ms
tc qdisc add dev eth1 root netem delay 30ms
tc qdisc add dev eth0 root netem delay 30ms # Internal latency
tc qdisc add dev eth1 root netem delay 50ms # External latency

echo "1" > /var/setup_done # This will be checked by our docker HEALTHCHECK

tail -f /dev/null
2 changes: 1 addition & 1 deletion hole-punch-interop/src/compose-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function run(namespace: string, compose: ComposeSpecification, logD
const stderrLogFile = path.join(logDir, `${sanitizedComposeName}.stderr`);

try {
const { stdout, stderr } = await exec(`docker compose -f ${path.join(dir, "compose.yaml")} up --exit-code-from alice --abort-on-container-exit`, { timeout: 15 * 1000 })
const { stdout, stderr } = await exec(`docker compose -f ${path.join(dir, "compose.yaml")} up --exit-code-from alice --abort-on-container-exit`, { timeout: 30 * 1000 })

await fs.writeFile(stdoutLogFile, stdout)
await fs.writeFile(stderrLogFile, stderr)
Expand Down
28 changes: 10 additions & 18 deletions hole-punch-interop/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
let startupScriptFn = (actor: "alice" | "bob") => (`
set -ex;
# Wait for router to be online
while ! ping -c 1 -w 1 "${actor}_router"; do sleep 1; done
# Wait for redis to be online
while ! ping -c 1 -w 1 "redis"; do sleep 1; done
ROUTER_IP=$$(dig +short ${actor}_router)
INTERNET_SUBNET=$$(curl --silent --unix-socket /var/run/docker.sock http://localhost/networks/${internetNetworkName} | jq -r '.IPAM.Config[0].Subnet')
Expand All @@ -107,12 +101,8 @@ function buildSpec(containerImages: { [key: string]: () => string }, {

let relayStartupScript = `
set -ex;
# Wait for redis to be online
while ! ping -c 1 -w 1 "redis"; do sleep 1; done
# Add RTT when using the relay
tc qdisc add dev eth0 root netem delay 50ms;
tc qdisc add dev eth0 root netem delay 50ms; # Add a delay to all relayed connections
/usr/bin/relay
`;
Expand Down Expand Up @@ -141,14 +131,15 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
cap_add: ["NET_ADMIN"]
},
alice: {
depends_on: ["relay", "alice_router"],
depends_on: ["relay", "alice_router", "redis"],
image: containerImages[aliceImage](),
init: true,
command: ["/bin/sh", "-c", startupScriptFn("alice")],
environment: {
TRANSPORT: transport,
MODE: "dial",
RUST_LOG: "debug"
RUST_LOG: "debug",
REDIS_TIMEOUT: 30
},
networks: {
alice_lan: {},
Expand All @@ -169,14 +160,15 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
cap_add: ["NET_ADMIN"]
},
bob: {
depends_on: ["relay", "bob_router"],
depends_on: ["relay", "bob_router", "redis"],
image: containerImages[bobImage](),
init: true,
command: ["/bin/sh", "-c", startupScriptFn("bob")],
environment: {
TRANSPORT: transport,
MODE: "listen",
RUST_LOG: "debug"
RUST_LOG: "debug",
REDIS_TIMEOUT: 30
},
networks: {
bob_lan: {},
Expand All @@ -188,8 +180,8 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
},
redis: {
image: "redis:7-alpine",
environment: {
REDIS_ARGS: "--loglevel warning"
healthcheck: {
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
},
networks: {
internet: {
Expand Down

0 comments on commit a53f3bc

Please sign in to comment.