Fix initial watch sync for existing files - #14031
Conversation
ndeloof
left a comment
There was a problem hiding this comment.
Verified locally, end to end: with a watched file antedated to 2020 (older than the service image) and initial_sync: true, a main build never syncs it at watch startup (/app/src: No such file or directory) while this branch does. New unit tests pass, the full pkg/compose suite and lint are green.
History check on the removed filter: the image-created-time condition was born with the feature itself (#12047, second commit) as a heuristic assuming watched files are baked into the image at build time — no later commit ever relied on or fixed it, so nothing regresses by removing it. It contradicted the pulled-image half of the original #11102 use case, and the removed imageCreatedTime helper was itself fragile (required an existing container, failed the whole initial sync otherwise). Same approach as #13728, which only got cosmetic review feedback before going stale.
Note: TestWatch/debian fails identically on main and on this branch in my environment (Docker Desktop restricted host mount on /var/folders) — pre-existing, unrelated.
Trade-off acknowledged: initial sync now copies the whole watched tree at watch start; acceptable since initial_sync is opt-in.
|
One request before this can merge: the PR includes |
3c8906f to
e4979a7
Compare
|
Thanks for the approval @ndeloof. Removed Force-pushed the branch ( |
develop.watch initial sync filtered host files by the service image's creation time, so files older than the image were never copied at watch startup even though later filesystem events synced them normally. Initial sync now copies every eligible watched file, keeping the ignore and bind-mount filtering. The imageCreatedTime helper it relied on is gone, and with it the project argument that only fed it. Fixes docker#13725 Signed-off-by: Ben Younes <2910651+ousamabenyounes@users.noreply.github.com>
f0efb7f to
a515d44
Compare
|
Rebased onto current |
initialSyncFiles and initialSyncDirectory filtered out any host file whose mtime predated the image creation time — which is exactly the files that initial_sync is meant to copy. The imageCreatedTime lookup (ContainerList + ImageInspect) was also a silent failure point when the container list returned nothing. Remove the filter and the helper entirely: sync all files that are not ignored or bind-mounted. Fixes #13725 Supersedes #14031 Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
What I did
Fixes #13725.
develop.watchinitial sync filtered host files by the service image's creation time. Existing files older than the image were therefore omitted at startup, even though later filesystem events synced them normally.Initial sync now copies every eligible watched file, while preserving ignore and bind-mount filtering. The obsolete image-time lookup is removed, and with it the
projectargument that only fed it.Rebased onto current
mainafter 68ab763 flattened the watch trigger preparation; the fix applies toinitialSyncFiles/initialSyncDirectoryin their new shape.Test verification
RED on
main(3ee4b5c79), with only the new test applied:GREEN with this change:
When the PR was opened I also checked this against a live Engine: reading
/app/src/test.txtat watch startup went fromNo such file or directorytohello.Validation
golangci-lint run --build-tags e2e ./...— 0 issuesgo test -tags e2eover./...minus e2e — every package passes, same set asmain;pkg/composecoverage 43.9% → 44.8%go build ./...,go vet ./..., and ago mod tidydiff check are clean