fix(watch): sync all files on initial_sync, regardless of mtime - #14096
Conversation
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 docker#13725 Supersedes docker#14031 Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The changes are correct and clean. This PR fixes a genuine bug (#13725) where initial_sync silently skipped pre-existing host files whose mtime predated the image creation time — exactly the files it was designed to copy.
What was removed and why it's safe:
imageCreatedTime/ContainerList+ImageInspectlookup: was a silent failure point (empty container list returned an error, blocking sync entirely). Correctly eliminated.mtimefilter ininitialSyncDirectory(thed.Info()+ModTime().Before()block): was the root-cause of #13725. Correctly removed.mtimeguard on the regular-file path ininitialSyncFiles: same fix applied symmetrically.
Remaining ignore/exclusion logic is intact: dockerignore patterns, ephemeral paths, .git/, trigger-level ignore lists, and bind-mount checks all still apply — only the mtime filter is gone.
Tests: Two new unit tests (TestInitialSyncFilesDirectory, TestInitialSyncFilesRegularFile) back-date files with os.Chtimes and verify they are now included, directly covering the regression.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
What I did
initialSyncFilesandinitialSyncDirectoryfiltered out any host file whose mtime predated the image creation time, which is exactly the files thatinitial_syncis meant to copy.The
imageCreatedTimelookup (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.
Related issue
Fixes #13725
Supersedes #14031
(not mandatory) A picture of a cute animal, if possible in relation to what you did
