Fetch env file from coordinator#1866
Open
sjg20 wants to merge 2 commits into
Open
Conversation
The lab admin currently has to distribute the env file to every client out of band - via a shared filesystem, git checkout, scp etc. This is awkward duplication for casual clients who just want to talk to a few boards from a remote machine. It also makes it harder to scale to larger labs with a lot of clients. For some labs, particularly smaller ones, the environment is very tied to the client, with each client having its own special file. For other labs, such as larger labs where changes are few, the environment is the same for each client. Add a new GetEnvironment RPC that returns the env file's text content, and a coordinator --environment flag pointing at the file to serve. The file is read fresh on each request, so admins can edit it in place and clients pick up the new version on their next invocation. The default (no --environment) is unchanged: GetEnvironment returns an empty string and clients keep loading env from a local file as before. Signed-off-by: Simon Glass <sjg@chromium.org>
Remote users have to keep a local copy of the lab env file in sync with the coordinator before they can run labgrid-client against it. This is friction for casual workflows like triage or console access from a laptop, and is awkward to maintain across many client machines. Provide a way for clients to fetch the env from the coordinator on startup. Setting LG_ENV (or --config) to the literal string 'coordinator:' issues a one-shot GetEnvironment RPC against the coordinator. The returned YAML is written under $XDG_CACHE_HOME/labgrid (or ~/.cache/labgrid) and loaded exactly as if the user had pointed at a local file, so the rest of the client is untouched. The cache file is overwritten on each fetch so users can inspect what env the client just loaded. Remote users then only need labgrid, network access to the coordinator and three environment variables (PATH, LG_COORDINATOR, LG_ENV=coordinator:) to run labgrid-client console -p <board> from anywhere. Per-user paths inside the served env (build dirs, log dirs, source trees) are still resolvable via the existing LG_* template substitution, so individual clients can override only the few values that matter to them without forking the env file. The coordinator address used for the fetch comes from --coordinator on the command line if given, otherwise LG_COORDINATOR, with 127.0.0.1:20408 as the final default - matching the fallback chain main() uses elsewhere. Signed-off-by: Simon Glass <sjg@chromium.org>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1866 +/- ##
========================================
- Coverage 46.0% 45.9% -0.1%
========================================
Files 180 180
Lines 14439 14472 +33
========================================
+ Hits 6654 6655 +1
- Misses 7785 7817 +32
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Description
Adds a way for
labgrid-clientto fetch the env file from the coordinator instead of requiring every user to keep a local copy in sync.GetEnvironmentRPC and an--environment FILEflag pointing at the YAML env file to serve. The file is read fresh on each request, so admins can edit it in place.coordinator:as a specialLG_ENV/--configvalue. When set, it issues a one-shotGetEnvironmentRPC, writes the YAML under$XDG_CACHE_HOME/labgrid(or~/.cache/labgrid), and loads it like any other env file. Per-user paths inside the served env are still resolvable via the existingLG_*template substitution.--environmentflag on the coordinator,GetEnvironmentreturns an empty string and clients keep loading env from a local file.What is the feature used for? Triage and console access from a laptop, scaling to larger labs with many clients, and removing the out-of-band env-file distribution step (shared FS, git checkout, scp, etc).
How does labgrid benefit? Lower friction for casual remote use - a remote user only needs
labgrid, network access to the coordinator and three env vars (PATH,LG_COORDINATOR,LG_ENV=coordinator:) to runlabgrid-client console -p <board>from anywhere.How was it verified? Ran the coordinator with
--environment <file>and a client withLG_ENV=coordinator:against it locally; confirmed the YAML is fetched, cached under~/.cache/labgrid, and that subsequent commands resolveLG_*template paths correctly. Confirmed that with no--environmentflag, behaviour is unchanged.No hardware-specific changes.
Checklist