Repository navigation
add support for internal-only args; use for dag-op - #10586
Conversation
| // loadDagOpID loads the target ID from the server. | ||
| // | ||
| // It takes two contexts, the first to load the receiver with, the second to | ||
| // load the current call with. This *ensures* that we aren't accidentally | ||
| // applying the dagop to multiple calls - only the most recent. | ||
| func loadDagOpID(ctx context.Context, loadCtx context.Context, srv *dagql.Server, id *call.ID) (dagql.Typed, error) { |
There was a problem hiding this comment.
@jedevc this was a surprise nice side effect; we can get rid of the little "dance of two contexts" here since now whether something should run in dag-op context is determined by args in the call rather than the actual context.Context
There was a problem hiding this comment.
Nice! Yes, agreed, this is a much better way of doing it 😁
jedevc
left a comment
There was a problem hiding this comment.
I'll be honest, I don't fully understand how/why this fixes the inputs thing from the pure dagql cache, but I'll take your word for it 😁
I think I can use this in the context of #10457 for the execution metadata? Maybe? Although it's a bit of a pain, since that whole struct caches kinda weirdly (by design).
Regardless, this is much neater than the context juggling we were hacking around with before.
| type cacheArgs struct { | ||
| Key string | ||
| Namespace string `default:""` | ||
| Namespace string `internal:"true" default:""` |
There was a problem hiding this comment.
This is probably worth adding a changelog for 😢
Yeah, it was always designed as an internal arg, but I think I have seen a couple cases of folks attempting to use it. No need to do any backwards compat, but should probably be in the changelog at least!
There was a problem hiding this comment.
You're right, added!
@jedevc It's basically that before this change:
The new cache logic is fancy enough to see "oh look, two calls to the same field with the exact same inputs, that's a cache hit", even when the exact return result digest doesn't match (since we handle multiple digests for a given result more robustly now). But after this change:
So it can actually see that the calls are distinct now and doesn't try to share cache for them. |
|
Right! Thanks, that clears it up a lot 🎉 |
This adds support for marking arguments to fields as internal, in which case they can only be set by internal server-side self calls and never by external clients in graphql requests. They won't show up in introspection schema requests either, so they never make it to SDKs or docs. We have wanted this in a variety of situations for a while, but the immediate motivation here is to update DagOp to use it to distinguish the "outer" lazy implementation and the "inner" call that actually triggers the execution of the operation. Previously we have accomplished that by plumbing things through context, but this no longer worked with the persistent dagql cache. That new caching implementation has logic such that even when digests of a call don't match, you can still get cache hits based on the inputs all being equivalent. Since inner/outer DagOp calls had the exact same inputs to the exact same field, they started incorrectly hitting cache for each other. Now, DagOps have internal args that indicate whether the real/inner operation should be executed unlazily and other metadata previously plumbed just through the LLB op. Besides the need from the persistent cache, this apprach feels like a good step in that it moves just a bit more logic/data away from LLB and into "dagger-native" code (i.e. into our actual API schema). This should be generally useful too for other situations where we have been forced to add args that really shouldn't be public in the interest of supporting internal server self calls, though this commit only updates DagOp-ified APIs for now. Signed-off-by: Erik Sipsma <[email protected]>
We never actually wanted this to be public, but previously didn't have a choice. Now we can mark it as internal so external clients can't set it; only our server-side internal calls can. Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Another spin-off from the persistent dagql cache work
This adds support for marking arguments to fields as internal, in which case they can only be set by internal server-side self calls and never by external clients in graphql requests. They won't show up in introspection schema requests either, so they never make it to SDKs or docs.
We have wanted this in a variety of situations for a while, but the immediate motivation here is to update DagOp to use it to distinguish the "outer" lazy implementation and the "inner" call that actually triggers the execution of the operation.
Previously we have accomplished that by plumbing things through context, but this no longer worked with the persistent dagql cache. That new caching implementation has logic such that even when digests of a call don't match, you can still get cache hits based on the inputs all being equivalent. Since inner/outer DagOp calls had the exact same inputs to the exact same field, they started incorrectly hitting cache for each other.
Now, DagOps have internal args that indicate whether the real/inner operation should be executed unlazily and other metadata previously plumbed just through the LLB op. This fixes the persistent cache use case since now there are actual inputs to the call that distinguish the outer+inner calls.
Besides the need from the persistent cache, this approach feels like a good step in that it moves just a bit more logic/data away from LLB and into "dagger-native" code (i.e. into our actual API schema).
This should be generally useful too for other situations where we have been forced to add args that really shouldn't be public in the interest of supporting internal server self calls. I pushed a second commit that uses it to hide the
namespacearg fromcacheVolume, which is something we've wanted for a while.TODO:
namespacearg toCacheVolumeto use this too since it's one of those APIs we didn't actually want to be public