- Notifications
You must be signed in to change notification settings - Fork1k
fix: return error if agent init script fails to download valid binary#13280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
6705c9e
d11c2d3
b63b479
5438b65
8f08e00
70e3091
3e121e0
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,7 +4,7 @@ set -eux | ||
# This is to allow folks to exec into a failed workspace and poke around to | ||
# troubleshoot. | ||
waitonexit() { | ||
echo "=== Agent script exited with non-zero code ($?). Sleeping 24h to preserve logs..." | ||
sleep 86400 | ||
} | ||
trap waitonexit EXIT | ||
@@ -31,4 +31,12 @@ fi | ||
export CODER_AGENT_AUTH="${AUTH_TYPE}" | ||
export CODER_AGENT_URL="${ACCESS_URL}" | ||
output=$(./${BINARY_NAME} --version | head -n1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I can't recall now, but I worry if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It's a good call-out, but IMHO I think we should use a different template replacement syntax than Bash's variable expansion, to make it very clear that these are replaced by a script and not accepted into the script as env vars. | ||
if ! echo "${output}" | grep -q Coder; then | ||
echo >&2 "ERROR: Downloaded agent binary returned unexpected version output" | ||
echo >&2 "${BINARY_NAME} --version output: \"${output}\"" | ||
exit 2 | ||
fi | ||
exec ./${BINARY_NAME} agent |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,7 +4,7 @@ set -eux | ||
# This is to allow folks to exec into a failed workspace and poke around to | ||
# troubleshoot. | ||
waitonexit() { | ||
echo "=== Agent script exited with non-zero code ($?). Sleeping 24h to preserve logs..." | ||
sleep 86400 | ||
} | ||
trap waitonexit EXIT | ||
@@ -86,4 +86,12 @@ fi | ||
export CODER_AGENT_AUTH="${AUTH_TYPE}" | ||
export CODER_AGENT_URL="${ACCESS_URL}" | ||
output=$(./${BINARY_NAME} --version | head -n1) | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I'd still like to see stderr redirected here so we can give a sensible output. Thoughts?
| ||
if ! echo "${output}" | grep -q Coder; then | ||
echo >&2 "ERROR: Downloaded agent binary returned unexpected version output" | ||
echo >&2 "${BINARY_NAME} --version output: \"${output}\"" | ||
exit 2 | ||
fi | ||
exec ./${BINARY_NAME} agent |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -35,6 +35,19 @@ if (-not (Get-Command 'Set-MpPreference' -ErrorAction SilentlyContinue)) { | ||
$env:CODER_AGENT_AUTH = "${AUTH_TYPE}" | ||
$env:CODER_AGENT_URL = "${ACCESS_URL}" | ||
$psi = [System.Diagnostics.ProcessStartInfo]::new("$env:TEMP\sshd.exe", '--version') | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
$psi.UseShellExecute = $false | ||
$psi.RedirectStandardOutput = $true | ||
$p = [System.Diagnostics.Process]::Start($psi) | ||
$output = $p.StandardOutput.ReadToEnd() | ||
$p.WaitForExit() | ||
if ($output -notlike "*Coder*") { | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
Write-Output "$env:TEMP\sshd.exe --version output: `"$output"`" | ||
Write-Error "ERROR: Downloaded agent binary returned unexpected version output" | ||
Throw "unexpected binary" | ||
} | ||
# Check if we're running inside a Windows container! | ||
$inContainer = $false | ||
if ((Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control' -Name 'ContainerType' -ErrorAction SilentlyContinue) -ne $null) { | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/envbash | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
set -euo pipefail | ||
# shellcheck source=scripts/lib.sh | ||