Skip to content

Commit 42b1cc5

Browse files
committed
warn, not error, on startup
1 parent c01de9b commit 42b1cc5

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

registry/coder-labs/modules/archive/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ module "archive" {
9797
archive_name = "my-archive"
9898
compression = "gzip"
9999
100-
# Waits up to 5 minutes for /tmp/my-archive.tar.gz to be present.
100+
# Waits up to 5 minutes for /tmp/my-archive.tar.gz to be present, note that
101+
# using a long timeout will delay every workspace start by this much until the
102+
# archive is present.
101103
extract_on_start = true
102104
extract_wait_timeout_seconds = 300
103105
}
@@ -114,7 +116,7 @@ module "archive" {
114116
- `directory` (string, default: `"~"`): Working directory used for tar with `-C`.
115117
- `create_on_stop` (bool, default: `false`): If true, registers a `run_on_stop` script that invokes the create wrapper on workspace stop.
116118
- `extract_on_start` (bool, default: `false`): If true, the installer waits up to `extract_wait_timeout_seconds` for the archive path to appear and extracts it on start.
117-
- `extract_wait_timeout_seconds` (number, default: `300`): Timeout for `extract_on_start`.
119+
- `extract_wait_timeout_seconds` (number, default: `5`): Timeout for `extract_on_start`.
118120

119121
## Outputs
120122

registry/coder-labs/modules/archive/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ variable "extract_on_start" {
6969
variable "extract_wait_timeout_seconds" {
7070
description = "Timeout (seconds) to wait for an archive when extract_on_start is true."
7171
type = number
72-
default = 300
72+
default = 5
7373
}
7474

7575
# Provide a stable script filename and sensible defaults.

registry/coder-labs/modules/archive/run.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,12 @@ echo "Installed extract script to: $EXTRACT_WRAPPER_PATH"
6464
if [[ $EXTRACT_ON_START = true ]]; then
6565
. "$LIB_PATH"
6666

67-
archive_wait_and_extract "$EXTRACT_WAIT_TIMEOUT"
67+
archive_wait_and_extract "$EXTRACT_WAIT_TIMEOUT" quiet || {
68+
exit_code=$?
69+
if [[ $exit_code -eq 2 ]]; then
70+
echo "WARNING: Archive not found in backup path (this is expected with new workspaces)."
71+
else
72+
exit $exit_code
73+
fi
74+
}
6875
fi

registry/coder-labs/modules/archive/scripts/archive-lib.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
# set -x
5-
64
log() {
75
printf '%s\n' "$@" >&2
86
}
@@ -253,6 +251,7 @@ archive_wait_and_extract() {
253251
load_defaults
254252

255253
local timeout="${1:-300}"
254+
local quiet="${2:-}"
256255
local file="${DEFAULT_ARCHIVE_PATH}"
257256

258257
local start now
@@ -273,6 +272,8 @@ archive_wait_and_extract() {
273272
sleep 5
274273
done
275274

276-
printf 'ERROR: Timed out waiting for archive: %s\n' "$file" >&2
277-
return 1
275+
if [[ -z $quiet ]]; then
276+
printf 'ERROR: Timed out waiting for archive: %s\n' "$file" >&2
277+
fi
278+
return 2
278279
}

0 commit comments

Comments
 (0)