fix: fail fast on container runners lacking NET_ADMIN (OSS-123)#84
Open
alexprivalov wants to merge 2 commits into
Open
fix: fail fast on container runners lacking NET_ADMIN (OSS-123)#84alexprivalov wants to merge 2 commits into
alexprivalov wants to merge 2 commits into
Conversation
Twingate must create a TUN interface, which requires CAP_NET_ADMIN. Unprivileged container runners (ubuntu-slim, container jobs without extra options) drop that capability, so the daemon starts but the tunnel never comes online — surfacing only as an endless "status: not-running" retry loop with no diagnostics. - Add check_network_capabilities() to linux-helpers.sh: verifies /dev/net/tun and CAP_NET_ADMIN (bounding set, bit 12) and prints actionable guidance (container.options: --cap-add NET_ADMIN --device /dev/net/tun) when missing. - Call it right after setup, before the retry loop, to fail fast instead of retrying silently for ~75s. - In debug mode, dump /var/log/twingated.log when systemd is absent (journalctl is empty on container runners). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the Linux start path for the action on container-based/minimal runners by detecting when the environment cannot support a VPN (missing /dev/net/tun and/or CAP_NET_ADMIN) and failing early with actionable guidance, instead of waiting through the retry loop; it also improves debug output when systemd/journald aren’t available.
Changes:
- Add
check_network_capabilities()inscripts/linux-helpers.shto validate/dev/net/tunandCAP_NET_ADMINviaCapBnd. - Call the new check immediately after
twingate setupin the Linux step to fail fast. - In debug mode, dump
/var/log/twingated.logwhen systemd is absent instead of relying onjournalctl.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/linux-helpers.sh | Adds a preflight check for TUN + CAP_NET_ADMIN to detect unsupported runners early. |
| action.yml | Invokes the preflight check before retrying and improves debug logs in non-systemd environments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Guard the CapBnd awk with `|| true` so an unreadable /proc/self/status yields "" instead of tripping `set -e` in the calling step. - Clarify the comment: TUN node often exists while CAP_NET_ADMIN is dropped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The action fails on
ubuntu-slimand other minimal/unprivileged container runners (e.g.blacksmith-4vcpu-ubuntu-2404), reported in #76 / OSS-123. The client installs fine, buttwingate startloops onstatus: 'not-running'for ~75s and then exits 1 with a generic "Twingate service failed to connect."Root cause
Twingate is a VPN — it must create and configure a TUN interface, which requires the
CAP_NET_ADMINcapability. These runners execute the job in an unprivileged container that dropsNET_ADMINfrom its capability set./dev/net/tundoes exist on these runners, so the client's existing device-node check passes (which is why the "docker run must be run with--cap-add NET_ADMIN" hint never appears).ioctl(tun_fd, TUNSETIFF)fails withoutCAP_NET_ADMIN, so the interface is never created and the tunnel never comes online./var/log/twingated.log, but the action's debug branch runsjournalctl -u twingate, which is empty without systemd — so the failure is invisible.Changes
scripts/linux-helpers.sh— newcheck_network_capabilities(): verifies/dev/net/tunandCAP_NET_ADMIN(parsed from theCapBndbounding set in/proc/self/status, bit 12). Prints actionable guidance when missing. Skips the cap check ifCapBndis unreadable (no false failures).action.yml— calls it right aftersetup, before the retry loop, to fail fast with guidance instead of retrying silently. Also dumps/var/log/twingated.login debug mode when systemd is absent.What this does / doesn't fix
container.options: --cap-add NET_ADMIN --device /dev/net/tun.ubuntu-slim: no way to add capabilities, so Twingate still cannot run there — but the action now fails immediately with a clear reason instead of a 75s silent timeout.Testing
Capability bit extraction verified against known cap sets:
000001ffffffffff(full)0000003fffffffff(VM runner)00000000a80425fb(Docker default)🤖 Generated with Claude Code