Skip to content

Fix initial watch sync for existing files - #14031

Open
ousamabenyounes wants to merge 1 commit into
docker:mainfrom
ousamabenyounes:13725-fix-initial-sync
Open

Fix initial watch sync for existing files#14031
ousamabenyounes wants to merge 1 commit into
docker:mainfrom
ousamabenyounes:13725-fix-initial-sync

Conversation

@ousamabenyounes

Copy link
Copy Markdown

What I did

Fixes #13725.

develop.watch initial 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.

Test verification

RED on upstream main (832673c8e445b5bf0bdb4963c7d7b3f81aa46da0):

TestInitialSyncFilesIncludesFilesOlderThanImage
paths: nil
expected: /app/src/test.txt
--- FAIL

GREEN with this change:

--- PASS: TestInitialSyncFilesIncludesFilesOlderThanImage
--- PASS: TestInitialSyncIncludesSingleFileOlderThanImage

The live Engine reproduction also changed from No such file or directory to successfully reading hello from /app/src/test.txt at watch startup.

Validation

Full local validation suite replayed on upstream and this branch:

  • golangci-lint run --build-tags e2e ./...0 issues
  • pkg/compose and all baseline-green unit packages pass
  • changed-line coverage gate passes
  • the same two container/inotify-dependent pkg/watch tests fail on both upstream and this branch; no new failures

@ousamabenyounes
ousamabenyounes requested review from a team as code owners August 11, 2026 23:53
ndeloof
ndeloof previously approved these changes Aug 12, 2026

@ndeloof ndeloof 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.

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.

@ndeloof
ndeloof enabled auto-merge (rebase) August 12, 2026 14:11
@ndeloof
ndeloof disabled auto-merge August 12, 2026 14:11
@ndeloof

ndeloof commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

One request before this can merge: the PR includes AI_AGENT_DISCLOSURE.md, which states the change "may not have been independently reviewed or tested" by its human submitter. That file is meant as a checkpoint, not something to merge: please review the code your agent produced yourself, then remove the file from the commit (amend/rebase) to confirm that manual review took place. The fix itself looks good — see the approval review — so this is the only thing left. (A CI check blocking merges while this file is present is being added.)

Signed-off-by: Ben Younes <2910651+ousamabenyounes@users.noreply.github.com>
@ousamabenyounes

Copy link
Copy Markdown
Author

Thanks for the approval @ndeloof. Removed AI_AGENT_DISCLOSURE.md from the commit and rebased onto the latest main. I reviewed the change myself before dropping the marker file.

Force-pushed the branch (3c8906f9be4979a7b0).

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.

[BUG] develop.watch initial_sync: true does not fire at container start

2 participants