Skip to content

wireguard: tolerate a failed public IP lookup - #2976

Merged
berendt merged 1 commit into
mainfrom
fix-wireguard-ip-lookup
Oct 18, 2026
Merged

berendt merged 1 commit into
mainfrom
fix-wireguard-ip-lookup

Conversation

@ideaship

Copy link
Copy Markdown
Contributor

scripts/prepare-wireguard-configuration.sh substitutes $(curl my.ip.fi) unquoted into a sed expression. When my.ip.fi returns an error page, curl still exits 0, the HTML is word-split into sed's arguments, and the deploy aborts in "Deploy manager + bootstrap nodes" with

sed: -e expression #1, char 37: unterminated `s' command

Seen twice, both with a 157-byte body (nginx's default 502 page):

  • testbed-deploy-current-in-a-nutshell-with-tempest-ubuntu-24.04, periodic-midnight 2026-10-18 (4cd1178d)
  • testbed-update-stable-current-ubuntu-24.04, 2026-01-04 (b5a3aa13)

The address only ends up in the client config fetched by the terraform Makefile's WireGuard target; the deployment never reads it. So:

  • curl -fsS --retry 3 --max-time 10 — HTTP errors fail, short outages are retried
  • substitute only a value that looks like an IPv4/IPv6 address
  • otherwise warn on stderr, keep the WIREGUARD_PUBLIC_IP_ADDRESS placeholder, and continue

Tested locally with a stub curl (IPv4, IPv6, curl -f failure, HTML body with exit 0); shellcheck clean.

🤖 Generated with Claude Code

prepare-wireguard-configuration.sh fills the manager's public address
into the WireGuard client configuration with an unquoted
$(curl my.ip.fi) inside the sed expression. When my.ip.fi answers
with an error page, curl still exits 0, the HTML is word-split into
sed's arguments and the deployment dies with

  sed: -e expression #1, char 37: unterminated `s' command

which says nothing about the actual cause. It happened on 2026-01-04
and 2026-10-18, both times with nginx's 502 Bad Gateway page.

The address is only used by the client configuration that users
fetch with the terraform Makefile's WireGuard target; nothing in the
deployment reads it. Losing a deployment over it is not warranted.

Fetch the address with curl -f, so HTTP errors count as failures, and
retry with a timeout. Only substitute it when it looks like an IPv4
or IPv6 address. Otherwise print a warning and leave the
WIREGUARD_PUBLIC_IP_ADDRESS placeholder, so the configuration visibly
needs a manual edit, and continue.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Roger Luethi <luethi@osism.tech>
@ideaship ideaship self-assigned this Oct 18, 2026
@ideaship
ideaship marked this pull request as ready for review October 18, 2026 12:11
@ideaship
ideaship requested a review from berendt October 18, 2026 12:11
@berendt
berendt merged commit 60697db into main Oct 18, 2026
3 checks passed
@berendt
berendt deleted the fix-wireguard-ip-lookup branch October 18, 2026 12:42
@github-project-automation github-project-automation Bot moved this from New to Done in Human Board Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants