watch: add tar sync implementation#10853
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## v2 #10853 +/- ##
==========================================
- Coverage 59.88% 58.37% -1.51%
==========================================
Files 118 119 +1
Lines 10064 10331 +267
==========================================
+ Hits 6027 6031 +4
- Misses 3440 3705 +265
+ Partials 597 595 -2
☔ View full report in Codecov by Sentry. |
Signed-off-by: Milas Bowman <[email protected]>
| @@ -0,0 +1,344 @@ | |||
| /* | |||
| Copyright 2018 The Tilt Dev Authors | |||
There was a problem hiding this comment.
I'm surprised the validation headers task doesn't complain about the Tilt line 🤔
Anyway this fine to have it 😉
| if useTar, _ := strconv.ParseBool(os.Getenv("COMPOSE_EXPERIMENTAL_WATCH_TAR")); useTar { | ||
| syncer = sync.NewTar(project.Name, tarDockerClient{s: s}) |
There was a problem hiding this comment.
Note: We'll need to discuss if we want to add a mode, strategy(or whatever the name) attribute to sync action or if we want Compose to automatically detect and choose the best sync option 🤔
There was a problem hiding this comment.
Yeah, for now I was doing this mostly so that I could incrementally add this and have an E2E run against both implementations while working.
Once things are merged in and look good, I think it might make sense to flip the default to enabled for one release so that watch users automatically get the updated experience but can switch back temporarily if needed.
There was a problem hiding this comment.
Long-term, I think the docker cp approach is "worse" in every scenario – the overhead of all the API calls is unavoidable (there's nothing actually wrong with the implementation). So I don't think we need to keep it.
But yes, considering we've discussed e.g. potential for daemon or alternative watch/sync implementations, it's probably worth thinking through what that might look like.
What I did
Add an alternative sync implementation based on the tilt-dev/tilt code:
rm -rfon paths that have been deleted on the hosttarcommand and write an archive tostdinwith the new/updated directories & filesFor now, this can be activated by setting
COMPOSE_EXPERIMENTAL_WATCH_TAR=1in the environment. The E2E watch test now runs both against both implementations.There's further opportunity for optimization, e.g. we end up
stating everything twice: once to determine if we should delete it upfront and once during thetar.Note that the actual invocation of this is still serial, i.e. change-by-change.
A follow-up PR will add batching within the watch code that invokes the sync with a debounce, similar to how it handles rebuilds.
Related issue
https://docker.atlassian.net/browse/ENV-191
(not mandatory) A picture of a cute animal, if possible in relation to what you did
