-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improving shared sessions #1432
Comments
Current LLB to session interactions happen in 2 ways. First, in every solve request client sends the session ID Line 207 in c44cb42
Op methods for the vertex, it attaches the session to the calling context. This actually has another issue that would use refactoring as vertex could have multiple sessions it should really pass all of them instead of a random one Lines 71 to 76 in c114e43
The second approach is that session ID can be attached directly to LLB with Lines 291 to 295 in c114e43
llb.SessionID()
Assuming (not sure if valid) shared sessions only make sense for transferring local sources as long as we use session IDs in LLB everything should be quite maintainable. We could improve the library so that What doesn't really work atm is sending a map of sessions to a frontend. There is no way to know if the frontend understands that convention or not. Atm. the existing frontend can only get one sessionID, so if, for example, |
I have trouble understanding this part at a conceptual level. Vertices may have multiple sessions when the edge digest is the same right? When vertices actually require attachables from the sessions (i.e. via SSH forwarding, secrets, file syncing), do they ever have multiple sessions? I suspect that since attachables are unique, vertices that have multiple sessions can pick a session at random because it won't actually utilize the attachables at all? Please let me know if I have the correct understanding.
Can you expand on this more? What do you mean by setting session IDs from locals?
Can you give an example of a session that is used for validation? How is validation performed?
This topic is on backward compatibility right? Perhaps we can make an attachable on a session so that you can lookup other session IDs. Basically expose a map on the single session. Maybe it also does session proxying for older frontends... not sure if these requests go through the gateway or not (if we have an opportunity to test capabilities of the frontend). |
Eg. look at
We could have a
There is no session validation atm. But basically it could be similar to entitlements. So when build request is made it sets a list of "allowed-sessionids" and then on LLB load, every local source that uses a session ID is checked against this list.
Yes. We shouldn't break using a new client against already built frontend.
Yes, there might be some hacky things that can be done.
We have but the problem atm is that these frontends have already been built. So there is no way to add new caps checks to the existing ones. |
I mean that if the session was a RPC on the gateway, it can check for a new field in the request, in order to detect if it's an older or newer frontend. I haven't read the code on how frontends interact with sessions (and their attachables) yet so just throwing out an idea here. |
Currently, management of the session is highly coupled with the
(*client.Client).solve
function. Thesolve
function does two things:SolveOpt
SessionPreInitialized == false
, which isfalse
by default.When trying to share a session, you may be running multiple solves with the same session in order to not repeat work like transferring local files. However, since the
solve
function does the work of initialization it is unnatural to run a solve first to initialize the session before handing off to possibly-parallel solves.Initialization does the following things:
attachables
which are additional GRPC servers registering on the client side. Whenbuildkitd
wants to, for example, transfer local files, then it invokes the RPC on theFileSync
service to read files from the client system. You can think of them as a capability granted by the client.attachables
.Sharing sessions is really only important for transferring local files because of duplicate work. For attachables that transfer secret files or forward SSH sockets, we want only want builds that require it to have it available in the session. As a result, builds should be able to support having multiple sessions; some sessions for shared attachables, some for attachables specific to this build.
The current solve interface sends a single session ID. On the
buildkitd
side, the session ID is added to thecontext.Context
, and then the relevant subsystem pulls the ID from thecontext.Context
and fetches the session from thesession.Manager
by the ID.We could send a map of attachable to session IDs like:
{"local:context:"session123", "local:dockerfile":"session345", "exporter": "session567", "default": "session890"}
.Client-side
On the client side, we'll need to create helper functions to make the default use case (no advanced usage of shared sessions) easy, but also decouple the sessions from the
solve
function so that its lifecycle is handled separately.Server
Do we want to store the mapping in the
context.Context
? It looks like it already delegates how to consume the session to the relevant subsystem, so for example thelocalExporter
will know what key to look for in the mapping in order to retrieve the correct session ID.The text was updated successfully, but these errors were encountered: