-
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
filesync: append rather than replace grpc md. #4049
Conversation
Couple notes:
No objections to this kind of change in general, but I am curious about what kind of metadata needs to be attached through the session mechanism in general 🤔 |
Yeah good call, if we are good with the change here then I'll update the other spots too!
For our use case, we purposely use our own I guess that just printing an error log in this case would be most backwards compatible as if someone for some reason was setting headers already that would collide the current behavior would be no error (since they are just ignored entirely atm), so changing that to be an error would be breaking. But that's also such an insanely obscure case maybe it doesn't matter. I'll update to print logs for now, let me know if anyone feels strongly about it being an error instead.
Yeah so the dagger PR where this need arose is moving the implementation of Dagger's API to no longer be "client-side" but instead be in the "server-side" We have dagger APIs built on top of the standard buildkit session attachables already with some light extra logic on top to enforce certain constraints that can depend on the current state of the filesystem local to the dagger client. By moving our API implementation to no longer be local to the client, we can no longer enforce all of those constraints by just reading the local filesystem and instead need to enforce them in the clients' session attachables. This is very easy to implement by just passing a few extra pieces of metadata from the API request to those attachables, but in order to do that we need the grpc metadata to makes it way there, which worked out-of-the-box for local import attachables, but not local export attachables, hence the fix here. |
Before this, CopyFileWriter just used metadata.NewOutgoingContext to set metadata, which results in any pre-existing metadata from the provided context to be removed. Now, it gets the current metadata and then sets its own on top of that, so any pre-existing unrelated metadata is retained. Signed-off-by: Erik Sipsma <erik@sipsma.dev>
5fad3dd
to
4b56395
Compare
I meant to leave this comment a few days ago but got distracted: I updated w/ the warning log in case metadata is gonna be overwritten somehow. For now, still only updating this one piece of the code since it's the only one impacting us, but if everyone's good with this change and would prefer squashing this everywhere, happy to also update the other parts of the code. Or I can just squash as they come up and leave as is for now, good with either. |
@tonistiigi wdyt? This likely has some conflicts with #2760, so since is a lot simpler, would be nice to get this in earlier. |
ping @tonistiigi |
Before this, CopyFileWriter just used metadata.NewOutgoingContext to set metadata, which results in any pre-existing metadata from the provided context to be removed.
Now, it gets the current metadata and then sets its own on top of that, so any pre-existing unrelated metadata is retained.
In Dagger we are integrating with buildkit at a somewhat deeper level and are making use of grpc metadata sent to client session attachables. There's a few other workarounds we can make if this change isn't desired for some reason, but overall just having buildkit retain unrelated grpc metadata during this call would be most convenient.