Skip to content

Add workshop identity to workshopctl requests - #1017

Open
tlm wants to merge 7 commits into
secrets-implementationfrom
system-sdk-secret-provider
Open

Add workshop identity to workshopctl requests#1017
tlm wants to merge 7 commits into
secrets-implementationfrom
system-sdk-secret-provider

Conversation

@tlm

@tlm tlm commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

Lay the groundwork for associating workshopctl requests with the workshop instance from which they originated.

Add user-scoped project lookup to workshop backends and expose the LXD instance UUID on loaded workshop metadata. The UUID is normalized to match the value written to /etc/machine-id.

Add request middleware that copies the optional workshop-instance-id header into the request context, and apply it to the workshopctl endpoint.

This change only propagates workshop identity. Validation of the supplied instance ID will be added separately.

LXD integration test identity

Update the LXD integration fixture to use the test runner's numeric UID and GID rather than assuming both are 1000. Workshop instance configuration uses these values in raw.idmap to map the owning host user to the fixed workshop user inside the container.

The previous fixture worked only on hosts where the test runner happened to use UID and GID 1000. On other hosts, those IDs can belong to different accounts or groups, causing LXD container creation to fail with operation not permitted. Using user.Current() makes the mapping represent the user actually running the test while retaining the synthetic testuser name and isolated LXD project. This is a test portability fix and does not change production identity handling.

Testing

  • go test ./internal/workshop/fakebackend ./internal/workshop/lxd ./internal/overlord/workshopstate
  • go test ./internal/daemon -check.f TestWithWorkshopInstanceID
  • go test -v -tags integration ./internal/workshop/lxd/tests/integration -check.v -check.f TestLxdBackendWorkshopInstanceID

Docs

  • I confirm the PR has no implications for documentation.

@tlm
tlm requested a review from dmitry-lyfar September 3, 2026 03:35
@tlm tlm self-assigned this Sep 3, 2026
@dmitry-lyfar

Copy link
Copy Markdown
Collaborator

@tlm I can review it, but I think the tests are failing

@tlm tlm mentioned this pull request Sep 4, 2026
10 tasks
tlm added 7 commits September 4, 2026 03:40
Expose UserProjects on the backend interface so callers can retrieve only the projects owned by the user in context without listing every user's projects.

Reuse the new method in the LXD and fake backend implementations and return an empty result when the context does not identify a user.
Add middleware that copies an optional workshop instance ID header into the request context for downstream handlers.

Define a shared typed context key and cover requests with and without the header while ensuring the next response function is always called.
Derive the test user's UID and GID from the user running the suite instead of assuming both are 1000.

This allows LXD raw ID mapping to work on hosts where the test runner uses different numeric user and group IDs.
Add an instance ID to workshop runtime metadata and populate it from LXD's volatile UUID, normalized to match the value written to /etc/machine-id.

Cover the mapping through the LXD backend integration suite.
Apply the workshop instance ID middleware to the workshopctl endpoint so a supplied instance ID is available to downstream request handling through the request context.
Use the invoking user's IDs for local integration runs, but retain the non-root workshop IDs when Spread executes the suite as root. This prevents LXD from trying to map host root into an unprivileged workshop instance.
@tlm
tlm force-pushed the system-sdk-secret-provider branch from 7283024 to d7624be Compare September 4, 2026 03:48
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