Auto-detect the client/host role from an existing API key - #463
Closed
sammy-vastai wants to merge 1 commit into
Closed
Auto-detect the client/host role from an existing API key#463sammy-vastai wants to merge 1 commit into
sammy-vastai wants to merge 1 commit into
Conversation
sammy-vastai
force-pushed
the
cln-3582-client-host-cli
branch
from
July 21, 2026 18:25
4f24e59 to
64ea70d
Compare
sammy-vastai
force-pushed
the
cln-3582-role-auto-detect
branch
from
July 21, 2026 18:25
f2307bc to
beb08e1
Compare
3 tasks
sammy-vastai
force-pushed
the
cln-3582-client-host-cli
branch
from
July 21, 2026 19:24
64ea70d to
180e92f
Compare
sammy-vastai
force-pushed
the
cln-3582-role-auto-detect
branch
from
July 21, 2026 19:24
beb08e1 to
318eb5a
Compare
2 tasks
Contributor
Author
sammy-vastai
added a commit
that referenced
this pull request
Jul 31, 2026
warm_role_cache() reads the API key from $XDG_CONFIG_HOME/vastai; run_install only overrode HOME, so an ambient XDG_CONFIG_HOME in the CI runner's own environment leaked through and pointed the check outside the sandbox. This is why warm_role_cache_fires_when_key_exists failed in every real GitHub Actions run (including all 3 runs of the original #463) despite passing locally every time — confirmed by reproducing the exact CI failure locally by injecting an ambient XDG_CONFIG_HOME.
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.
Summary
Stacked on #462. Adds automatic role detection so most users never have to run
vastai set rolemanually — the key insight is that for most existing users an API key already exists, so there's no "enter your key" moment to hook into; detection just needs to use it as soon as possible.ensure_host_role_detected()(vastai/cli/util.py): one best-effort API call (GET /machines?owner=me) that caches the role permanently either way ('client' as much as 'host') on success; a failed check (network/auth error) leaves it undetected for retry rather than guessing.get_client()(vastai/cli/utils.py) — fires lazily on a user's next real command. Deliberately does not run on--help/tab completion, which never build a client.vastai set api-key— detects immediately using the newly-saved key and announces the result.scripts/install.sh) — if a key already exists on disk (a pre-existing user re-running the installer to upgrade), fires a single detached (nohup ... & disown) background call so it can't add install latency.get_client()lazy path, an accepted, unavoidable gap.vastai set role host|clientremains the deliberate override for e.g. a client account that starts hosting later.Test plan
poetry run pytest tests/cli— 407 passedbash tests/installer/run_tests.sh— 18 passed (3 new scenarios covering the installer's background role-detection)set api-keyauto-detection and announcement against the realvastaibinaryCLN-3582