Skip to content

vm: inotify: also trigger IN_CLOSE_WRITE when syncing file events - #1643

Merged
abiosoft merged 1 commit into
abiosoft:mainfrom
flozero:inotify-close-write
Oct 2, 2026
Merged

abiosoft merged 1 commit into
abiosoft:mainfrom
flozero:inotify-close-write

Conversation

@florentigiraud-flare

@florentigiraud-flare florentigiraud-flare commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1244. Related: #1341.

Problem

With --mount-inotify, Colima replays host file changes in the guest by running chmod with the file's current mode. Containers therefore only receive IN_ATTRIB. Watchers that ignore attribute-only events never react, for example Pants (pants --loop), which drops every metadata change except permissions (source), or air (#1341).

Change

The sync command now also opens the file for writing and closes it, without writing anything:

-sudo /bin/chmod <mode> <path>
+sudo /bin/sh -c '/bin/chmod "$1" "$2" && : >> "$2"' sh <mode> <path>
  • chmod is kept, so watchers that rely on IN_ATTRIB behave exactly as before.
  • : >> "$2" opens the file in append mode and closes it, which makes the kernel emit IN_OPEN + IN_CLOSE_WRITE. No byte is written.
  • The mode and path are passed as positional arguments, not interpolated into the script, so paths with spaces or quotes are safe.

The command is built by a small syncEventCmd() helper so it can be unit tested.

Why it doesn't hit the editor problem from #1244

As we don't change the file on the host the editor shoud not be confuse with that.

Tests

  • events_test.go: unit test of the generated command, including a path with spaces and quotes.
  • events_linux_test.go (Linux only, runs in CI): runs the command on a temp file, then asserts that inotify reports IN_ATTRIB and IN_CLOSE_WRITE but not IN_MODIFY, and

The command is built by a small syncEventCmd() helper so it can be unit tested.

Manual end-to-end test (macOS 26.7 Apple Silicon, vz + virtiofs, docker runtime) on a real multi-container dev stack, editing files on the host:

  • pants --loop test: now reruns tests (didn't react before);
  • uvicorn/watchfiles, gunicorn --reload, Vite dev server, cargo watch: still reload as before.

LLM usage disclosure

This change was written with the help of an LLM (Claude): the investigation and the fix. The test was written manually with some guidance of claude because it's not a language I am confident enough to write something good but I reviewed every line and ran all the tests above myself.

Signed-off-by: Florent Giraud <florent.giraud@flare.io>
@abiosoft

abiosoft commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Thanks :)

@abiosoft abiosoft changed the title inotify: also trigger IN_CLOSE_WRITE when syncing file events vm: inotify: also trigger IN_CLOSE_WRITE when syncing file events Oct 2, 2026
@abiosoft
abiosoft merged commit 49dfe87 into abiosoft:main Oct 2, 2026
17 checks passed
@florentigiraud-flare

Copy link
Copy Markdown
Contributor Author

Thank you for the merge 🙏 🚀 just checking with you when do you think the release will be ?

@florentigiraud-flare
florentigiraud-flare deleted the inotify-close-write branch October 2, 2026 14:44
@abiosoft

abiosoft commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Thank you for the merge 🙏 🚀 just checking with you when do you think the release will be ?

Hopefully within a week.

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.

All inotify filesystem events are chmod/attribute events

2 participants