Skip to content

fix(worker): keep tunnel cleanup consistent - #3

Merged
ostenbom merged 2 commits into
mainfrom
fix/tunnel-cleanup-consistency
Sep 18, 2026
Merged

ostenbom merged 2 commits into
mainfrom
fix/tunnel-cleanup-consistency

Conversation

@ostenbom

@ostenbom ostenbom commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • delete a tunnel DNS record before deleting the Cloudflare tunnel
  • treat an already-missing DNS record as successful cleanup so retries remain idempotent

Why

The scheduled cleanup previously deleted the Cloudflare tunnel before looking up and deleting its DNS record. If the DNS lookup or deletion then failed, cleanup retained the LINKUP_TUNNELS KV entry even though the tunnel was already gone. Subsequent linkup start calls reused those stale credentials and cloudflared failed with Unauthorized: Tunnel not found.

Performing DNS cleanup first ensures DNS failures leave the tunnel and KV record consistent. If tunnel deletion fails after DNS deletion, the next cleanup attempt tolerates the missing DNS record and retries the tunnel deletion.

Validation

  • cargo test -p linkup-worker
  • cargo clippy -p linkup-worker --all-targets -- -D warnings
  • cargo fmt --all -- --check

@ostenbom
ostenbom force-pushed the fix/tunnel-cleanup-consistency branch from 4f2b77a to 9d0c158 Compare September 18, 2026 09:34
@ostenbom
ostenbom merged commit efc4c71 into main Sep 18, 2026
6 checks passed
augustoccesar pushed a commit that referenced this pull request Oct 8, 2026
## Summary

- delete a tunnel DNS record before deleting the Cloudflare tunnel
- treat an already-missing DNS record as successful cleanup so retries
remain idempotent

## Why

The scheduled cleanup previously deleted the Cloudflare tunnel before
looking up and deleting its DNS record. If the DNS lookup or deletion
then failed, cleanup retained the `LINKUP_TUNNELS` KV entry even though
the tunnel was already gone. Subsequent `linkup start` calls reused
those stale credentials and cloudflared failed with `Unauthorized:
Tunnel not found`.

Performing DNS cleanup first ensures DNS failures leave the tunnel and
KV record consistent. If tunnel deletion fails after DNS deletion, the
next cleanup attempt tolerates the missing DNS record and retries the
tunnel deletion.

## Validation

- `cargo test -p linkup-worker`
- `cargo clippy -p linkup-worker --all-targets -- -D warnings`
- `cargo fmt --all -- --check`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants