Skip to content

feat: lift HTTP implementation to dagger - #10317

Merged
jedevc merged 11 commits into
dagger:mainfrom
jedevc:http-dagop
May 13, 2025
Merged

jedevc merged 11 commits into
dagger:mainfrom
jedevc:http-dagop

Conversation

@jedevc

@jedevc jedevc commented May 2, 2025 •

Copy link
Copy Markdown
Contributor

In #9980, we lifted our custom git implementation entirely into dagger using dagop (#9395). In this PR, we do exactly the same, but for our custom http source.

Additionally, while in the area, I've added a couple features:

  • Added auth header support
  • Allow overwriting filename + permissions

TODO:

  • Lift all HTTP code to dagger
    • Support ETags
  • Add new tests for exact caching behavior we want - we have no tests for this
  • Add support for HTTP authentication (would rather add this now, since it might affect structure of caching)
  • Tidy up code
    • TODOs
    • Move ref creation mounting entirely out of dagop (since we can do this outside of dagop 😁)

@jedevc
jedevc force-pushed the http-dagop branch 2 times, most recently from 38cf98b to 0dffb31 Compare May 8, 2025 15:48
@jedevc
jedevc marked this pull request as ready for review May 8, 2025 15:51
@jedevc
jedevc requested review from a team as code owners May 8, 2025 15:51
@jedevc
jedevc requested review from sipsma and removed request for a team May 8, 2025 15:51
@jedevc
jedevc force-pushed the http-dagop branch 2 times, most recently from 6bef4aa to 252cf4e Compare May 8, 2025 16:26
Comment thread .dagger/main.go
var err error
engine = dev.Engine().Generate()
docs, err = engine.Sync(ctx)
engine, err = engine.Sync(ctx)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh dear

@jedevc jedevc mentioned this pull request May 9, 2025
5 of 23 tasks
@jedevc
jedevc force-pushed the http-dagop branch 3 times, most recently from dafd794 to 2c12dff Compare May 12, 2025 10:32
Comment thread core/schema/container.go
}

func (s *containerSchema) asTarballPath(ctx context.Context, val dagql.Instance[*core.Container]) (string, error) {
func (s *containerSchema) asTarballPath(ctx context.Context, val dagql.Instance[*core.Container], _ containerAsTarballArgs) (string, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing what required this change (doesn't matter either way though)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function gets passed to dagop - and the HTTP path function uses the args from the main call to determine the path.

So, if you download https://example.com/foo.txt, the filename you download it to is foo.txt (which felt like it made sense, previously the name wasn't significant, because we needed to get certain buildkit caching behavior).

Comment thread core/schema/http.go

st := httpdns.HTTP(args.URL, clientMetadata.SessionID, opts...)
return core.NewFileSt(ctx, parent, st, filename, parent.Platform(), svcs)
// evaluate now! so that the snapshot definitely lives long enough

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we lose laziness that we had previously, right? Or is it more complicated.

Not a blocker necessarily, mostly just double checking for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, more complicated 😢 the way buildkit handles this:

  • During CacheKey it creates and immediately releases a snapshot, saving it on the source
  • During Exec it looks for the saved snapshot, if it's not there, it recreates it (by dedownloading)

So previously we were always creating a snapshot in CacheKey - this is pretty much the same kind of behavior, the HTTP source isn't really very lazy (since there's no authoritative way to quickly query the digest of an arbitrary remote URL).

@jedevc jedevc added the needs/changelog Pull requests that require a changelog entry label May 13, 2025
jedevc added 2 commits May 13, 2025 09:59
Without this, the function can't be called from the CLI.

Signed-off-by: Justin Chadwell <[email protected]>
jedevc added 7 commits May 13, 2025 09:59
- Allow passing arbitrary data to dagop directly
- Rework digest calculations (so we can control it more precisely in the future)
- Remove cache access from dagop, and lift it into the Query (so we can
  create cache refs outside of dagop)

Signed-off-by: Justin Chadwell <[email protected]>
Checks for all the behavior we want:
- Arg overrides
- ETag handling
- Timestamps
- Caching

Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
@jedevc jedevc added this to the v0.18.7 milestone May 13, 2025
- Ensure that we correctly propagate + smuggle dagop data in all cases
  (it's not part of the cache key, but definitely is part of the digest)
- Include filename + permissions in the url hash (so that we don't
  accidentally use the wrong snapshots).
- Ensure HTTP snapshots are always freed! (we sometimes weren't)

Signed-off-by: Justin Chadwell <[email protected]>
@jedevc

jedevc commented May 13, 2025

Copy link
Copy Markdown
Contributor Author

Hit a new test flake in TestHTTP/TestHTTPPermissions and realized I had a little bug in doing the snapshot etag lookup - have patched that, and another couple of minor bits.

@jedevc
jedevc merged commit 54a7d54 into dagger:main May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs/changelog Pull requests that require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants