Skip to content

feat: Host.Directory dagOp migration (localSource) - #10995

Merged
TomChv merged 18 commits into
dagger:mainfrom
TomChv:feat/host-directory-dagopify
Oct 20, 2025
Merged

TomChv merged 18 commits into
dagger:mainfrom
TomChv:feat/host-directory-dagopify

Conversation

@TomChv

@TomChv TomChv commented Sep 5, 2025 •

Copy link
Copy Markdown
Member

Convert Host.Directory to a dagOp operation.

Changes

  • Remove llb.Local usage and directly call localSource.Snapshot instead
  • Expose localSource on the dagQL server
  • Extend localSource option so it can support new option like GitIgnore
  • Change localSource.Snapshot behaviour so it can directly return a snapshot of the expected directory instead of doing extra job after the snapshot to move to the directory (basically we don't need to call .Directory after snapshot)
  • Wrap Host.Directory into a DagOp

TODO

  • Remove DummySource when we are sure it's never called
  • Understand what's wrong with TestHost/TestDirectoryGitIgnore/don't_load_files_ignored_by_.gitignore

@jedevc jedevc mentioned this pull request Sep 15, 2025
5 of 23 tasks
@TomChv
TomChv force-pushed the feat/host-directory-dagopify branch from 74c3dd8 to 8c7394b Compare September 19, 2025 11:59
Comment thread core/schema/host.go Resolved
@TomChv
TomChv force-pushed the feat/host-directory-dagopify branch 2 times, most recently from 600952e to aac284a Compare September 25, 2025 12:59
@TomChv

This comment was marked as resolved.

@TomChv

This comment was marked as resolved.

@TomChv
TomChv force-pushed the feat/host-directory-dagopify branch from 6a90d53 to 3541386 Compare September 29, 2025 16:55
@TomChv
TomChv marked this pull request as ready for review September 29, 2025 17:47
@TomChv TomChv changed the title feat: LocalSource dagOp migration (WIP) feat: Host.Directory dagOp migration (localSource) Sep 29, 2025
@TomChv
TomChv requested a review from jedevc September 30, 2025 11:49
Comment thread engine/sources/local/source.go Resolved
Comment thread engine/sources/local/source.go Outdated
id.Differ = fsutil.DiffNone
}
}
// TODO: Write a dummy local source to verify that we never use llb.Local anymore

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.

👀

Comment thread engine/sources/local/source.go Resolved
Comment thread engine/sources/local/source.go Outdated
Comment on lines +81 to +82
// If relPath is ".", we want to use the root path so we can unset it
// because `"."` leads to unnecessary complications inside snapshot.

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.

Does it? That's strange.

The only type of path cleaning I'd expect to see here would be with filepath.Clean.

@TomChv TomChv Oct 1, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

filepath.Clean(".") returns "." and that makes local.Sync quite complex to do.

For example strings.CutPrefix("bar", ".") will return "bar", false while technically which will skip the cache change even though we should do it.
Same in copier.copy, if srcComponents = ".", that will change the logic etc...

So I have 2 choices:

  • Set relPath to "" if it's "."
  • Do a bunch of if relpath == "." to adapt the logic in localfs & copy.

I took the choice of simplicity there, but if you see a reason to go the other way or have another idea, I'm happy to discuss about it :D

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.

Nope, that's a good explanation.

So either:

  • update the comment to replace "unneccessary complications" with that detail
  • or just remove "unneccessary complications" entirely, imo, that's fairly clear

Comment thread engine/sources/local/source.go Resolved
Comment thread engine/sources/local/source.go Resolved
Comment thread core/schema/host.go Outdated
Comment on lines +245 to +248
// The operation is not wrapped in dagOp at the schema level, so we manually handle
// it inside the resolver.
// That's because it's more convenient to call `MakeDirectoryContentHashed` here
// that having an option in the `dagOpDirectoryWrapper`

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.

As we discussed previously - we should add an arg to the wrapper to call MakeDirectoryContentHashed on the result - that should simplify the need to mess around with args.InDagOp here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There's no other function that host.Directory that actually calls MakeDirectoryContentHashed so I thought it would not be useful to add an arg in the wrapper for a single case.

Do you think it's worth going the general way for a single function?

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.

It'll hugely simplify this function :) so worth it IMO.

Just because we're only using it one place now, doesn't mean we won't want to use it in more places in the future.

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.

This comment is not true anymore.

@TomChv
TomChv force-pushed the feat/host-directory-dagopify branch 2 times, most recently from a4429da to 6766583 Compare October 7, 2025 00:34

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.

We could simplify by removing the windows files and just consolidate entirely under one file.

This is all engine-side, we only support Linux. If we ever extend to support Windows, IMO, there's a lot of bigger issues.

@sipsma any reason to keep these around?

@jedevc jedevc left a comment

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.

Couple of comments, but LGTM 🎉

cc @sipsma if you want to take a quick look!

Comment thread engine/filesync/localfs.go Resolved
Comment thread engine/server/server.go Resolved
Comment thread engine/filesync/tracing.go Resolved
@jedevc
jedevc requested a review from sipsma October 7, 2025 10:10
@TomChv
TomChv force-pushed the feat/host-directory-dagopify branch from 6766583 to 7e19608 Compare October 9, 2025 17:57
@TomChv TomChv self-assigned this Oct 9, 2025
@TomChv
TomChv requested a review from jedevc October 10, 2025 13:24

@jedevc jedevc left a comment

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.

Couple nits, merge when fixed!

Comment thread core/schema/host.go
dagql.NodeFuncWithCacheKey("directory",
DagOpDirectoryWrapper(
srv, s.directory,
WithHashContentDir[*core.Host, hostDirectoryArgs](),

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 think you can omit the generic args here, they should be implied from the context?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Screenshot 2025-10-20 at 15 04 22

Comment thread core/schema/host.go Outdated
Comment on lines +245 to +248
// The operation is not wrapped in dagOp at the schema level, so we manually handle
// it inside the resolver.
// That's because it's more convenient to call `MakeDirectoryContentHashed` here
// that having an option in the `dagOpDirectoryWrapper`

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.

This comment is not true anymore.

@jedevc jedevc added this to the v0.19.3 milestone Oct 20, 2025
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
TomChv added 10 commits October 20, 2025 15:03
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
- move `engine/sources/local` to `engine/filesync`
- Rename `LocalSource` to `FileSyncer`

Signed-off-by: Tom Chauveau <[email protected]>
@TomChv
TomChv force-pushed the feat/host-directory-dagopify branch from 7e19608 to 748fbc9 Compare October 20, 2025 22:04
@TomChv
TomChv merged commit 62929bd into dagger:main Oct 20, 2025
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