Skip to content

Commit 310f148

Browse files
authored
fix(dogfood/coder): add shutdown script and graceful agent shutdown (#17110)
By stopping Docker, we can hopefully avoid errors like this: ``` 2025-03-26 12:14:53.280+02:00 Error: Error deleting container aa313fca0f72e59d4571afec898392e0ae34567d56c0ad15554c87394d2ca1e1: Error response from daemon: container aa313fca0f72e59d4571afec898392e0ae34567d56c0ad15554c87394d2ca1e1: driver "overlay2" failed to remove root filesystem: unlinkat /var/data/docker/overlay2/2e8e509237c79ebec972cccae9867f3bd6f71d49d4ed68db1b5ba229c3a2ff62/diff/var/lib/docker/overlay2/9c7c4ab0187ece1ca270d146090a8e852808996279d103cb394b2821c472af4c/diff/usr/lib/python3/dist-packages/ansible_collections: directory not empty ```
1 parent c8f3b35 commit 310f148

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

dogfood/coder/main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,14 @@ resource "coder_agent" "dev" {
357357
cd "${local.repo_dir}" && make clean
358358
cd "${local.repo_dir}/site" && pnpm install
359359
EOT
360+
361+
shutdown_script = <<-EOT
362+
#!/usr/bin/env bash
363+
set -eux -o pipefail
364+
365+
# Stop the Docker service to prevent errors during workspace destroy.
366+
sudo service docker stop
367+
EOT
360368
}
361369

362370
# Add a cost so we get some quota usage in dev.coder.com
@@ -418,6 +426,10 @@ resource "docker_container" "workspace" {
418426
# CPU limits are unnecessary since Docker will load balance automatically
419427
memory = data.coder_workspace_owner.me.name == "code-asher" ? 65536 : 32768
420428
runtime = "sysbox-runc"
429+
# Ensure the workspace is given time to execute shutdown scripts.
430+
destroy_grace_seconds = 60
431+
stop_timeout = 60
432+
stop_signal = "SIGINT"
421433
env = [
422434
"CODER_AGENT_TOKEN=${coder_agent.dev.token}",
423435
"USE_CAP_NET_ADMIN=true",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy