pkg/cdi: fix cache refresh handling for filesystem events - #344
Conversation
|
Let me just push the branch I had locally for my own sanity; I think I had some work remaining (last commit), but started to loose track of splitting out to small PRs (for easier review). |
|
Ah, right; I needed a go bump for some bits; |
542d33f to
f9ff5c5
Compare
1e69ccb to
5b6a40e
Compare
edd59f9 to
ef6c91f
Compare
Handle removal of watched Spec directories separately from restoring missing watches. Previously update() accepted an optional removed directory and marked it as unwatched only after attempting to restore other missing watches. This required callers to distinguish between normal updates and directory removal, and caused update() to serve two separate purposes. Add markRemoved() to update the watch state when fsnotify reports that a watched directory was removed, then call update() unconditionally to restore any watches that are currently missing. This also allows a directory that was removed and recreated concurrently to have its watch restored immediately. This keeps update() focused on reconciling missing watches and removes the special-case removed-directory argument. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Include fsnotify.Create in the event mask on all platforms instead of only on macOS. Spec files can be written atomically by creating a temporary file and renaming it into place. On Linux, fsnotify reports the destination of such a rename as a Create event. Without watching Create events, the cache may miss the new Spec and only refresh because of an unrelated event for the temporary file. Watching Create events directly ensures that newly created or atomically replaced Spec files trigger a cache refresh on all platforms. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
`fsnotify.Event.Op` is a bitmask and can contain multiple operations, but the watcher compared it directly against individual operation values. As a result, combined events could bypass operation-specific handling, such as filtering writes and creates by file extension or detecting removal of a watched directory. Mask the operations we are interested in and test the individual bits instead. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The watcher filtered write and create events by file extension, but rename and remove events for unrelated files would still trigger a refresh of the CDI cache. Apply the same Spec-file filtering to all relevant filesystem events, while still processing events for configured Spec directories themselves. This avoids unnecessary rescans when non-Spec files in watched directories are renamed or removed, without interfering with handling of removed Spec directories. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| eventMask := fsnotify.Rename | fsnotify.Remove | fsnotify.Write | ||
| // On macOS, we also need to watch for Create events. | ||
| if runtime.GOOS == "darwin" { | ||
| eventMask |= fsnotify.Create | ||
| } | ||
| // Watch for Spec file changes. Atomic writes may create a temporary file and | ||
| // rename it into place. On Linux, fsnotify reports the destination of such a | ||
| // rename as a Create event, so Create must be watched on all platforms. | ||
| eventMask := fsnotify.Create | fsnotify.Rename | fsnotify.Remove | fsnotify.Write |
There was a problem hiding this comment.
This is what previously caused the failures; my changes exposed this issue.
Had to (for testing) update to fsnotify 1.8, which added FSNOTIFY_DEBUG for debugging the events
|
@klihub @elezar @bart0sh this is the last set of patches I had lined up 😅
Slightly wondering if v1.7 is too conservative, and if we should bump to a slightly newer version, but we can leave that to consumers of this module. |
I'd be ok with bumping to v1.8 as well. Did you want to do it in this PR, or as a separate dependency bump? |
Let's do that separately later if we decide to do so. I think @thaJeztah only needed that for devel/debugging while working on this PR. No other pressing reasons for the bump. |
|
I'd be fine keeping it at 1.7, sticking to MVS and leaving it to consumers to update if they want. (although probably not many will be on such old versions). |
|
(I tried newer versions ( > 1.6) last week to see if they had a meaningful impact on indirect dependencies, but they didn't, so I picked 1.7 as a minimum) |
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [tags.cncf.io/container-device-interface](https://github.com/cncf-tags/container-device-interface) | `v1.1.0` → `v1.1.1` |  |  | --- ### Release Notes <details> <summary>cncf-tags/container-device-interface (tags.cncf.io/container-device-interface)</summary> ### [`v1.1.1`](https://github.com/cncf-tags/container-device-interface/releases/tag/v1.1.1) [Compare Source](cncf-tags/container-device-interface@v1.1.0...v1.1.1) #### What's Changed - spec: Fix comment to reference containerEdits field by [@​zrezke](https://github.com/zrezke) in [#​303](cncf-tags/container-device-interface#303) - cdi: inject mount UID/GID mappings if user NS is in use. by [@​klihub](https://github.com/klihub) in [#​288](cncf-tags/container-device-interface#288) - cdi,SPECS.md: allow empty cgroup permissions. by [@​klihub](https://github.com/klihub) in [#​301](cncf-tags/container-device-interface#301) - .github: bump golangci-lint to v2.9.0. by [@​klihub](https://github.com/klihub) in [#​307](cncf-tags/container-device-interface#307) - add local build and install procedure in README.md. by [@​fujitatomoya](https://github.com/fujitatomoya) in [#​305](cncf-tags/container-device-interface#305) - Revert to default spec dirs if none are specified by [@​elezar](https://github.com/elezar) in [#​310](cncf-tags/container-device-interface#310) - SPEC.md: fix a few typos/clarify a sentence. by [@​klihub](https://github.com/klihub) in [#​312](cncf-tags/container-device-interface#312) - add beginner's tutorial to see how CDI works. by [@​fujitatomoya](https://github.com/fujitatomoya) in [#​311](cncf-tags/container-device-interface#311) - Makefile: add GO\_EXTRAFLAGS to go build call by [@​koenkooi](https://github.com/koenkooi) in [#​313](cncf-tags/container-device-interface#313) - Remove runtime-tools dependency by [@​elezar](https://github.com/elezar) in [#​317](cncf-tags/container-device-interface#317) - schema: add validation for top-level container edits by [@​marquiz](https://github.com/marquiz) in [#​323](cncf-tags/container-device-interface#323) - parser: guard single-character vendor and class names against a slice-bounds panic by [@​thc1006](https://github.com/thc1006) in [#​321](cncf-tags/container-device-interface#321) - chore(deps): replace deprecated gopkg.in/yaml.v3 for go.yaml.in/yaml/v3 by [@​thaJeztah](https://github.com/thaJeztah) in [#​328](cncf-tags/container-device-interface#328) - schema: make validation error private by [@​thaJeztah](https://github.com/thaJeztah) in [#​329](cncf-tags/container-device-interface#329) - pkg/cdi: stop embedding Cache mutex by [@​thaJeztah](https://github.com/thaJeztah) in [#​335](cncf-tags/container-device-interface#335) - build(deps): bump actions/stale from 10 to 11 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​327](cncf-tags/container-device-interface#327) - specs-go: add test coverage by [@​thaJeztah](https://github.com/thaJeztah) in [#​332](cncf-tags/container-device-interface#332) - replace strings.Split for strings.Cut by [@​thaJeztah](https://github.com/thaJeztah) in [#​336](cncf-tags/container-device-interface#336) - schema, validation: minor fixes and modernization by [@​thaJeztah](https://github.com/thaJeztah) in [#​330](cncf-tags/container-device-interface#330) - pkg/cdi: deprecate ErrStopScan and use os.ReadDir for scanning Spec directories by [@​thaJeztah](https://github.com/thaJeztah) in [#​339](cncf-tags/container-device-interface#339) - Bump actions/checkout from 6 to 7 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​318](cncf-tags/container-device-interface#318) - pkg/cdi: synchronize access to specDirs by [@​thaJeztah](https://github.com/thaJeztah) in [#​337](cncf-tags/container-device-interface#337) - schema: migrate to github.com/santhosh-tekuri/jsonschema/v6 by [@​thaJeztah](https://github.com/thaJeztah) in [#​331](cncf-tags/container-device-interface#331) - pkg/cdi: fix deprecations, add doc-links and "go fix" by [@​thaJeztah](https://github.com/thaJeztah) in [#​338](cncf-tags/container-device-interface#338) - internal/validation/k8s: remove unused validation helpers by [@​thaJeztah](https://github.com/thaJeztah) in [#​334](cncf-tags/container-device-interface#334) - specs-go: remove x/mod semver dependency by [@​thaJeztah](https://github.com/thaJeztah) in [#​333](cncf-tags/container-device-interface#333) - chore(deps): github.com/stretchr/testify v1.12.1 by [@​thaJeztah](https://github.com/thaJeztah) in [#​342](cncf-tags/container-device-interface#342) - ci: update golangci-lint to v2.13, and fix linting by [@​thaJeztah](https://github.com/thaJeztah) in [#​352](cncf-tags/container-device-interface#352) - ci: apply zizmor hardening fixes by [@​thaJeztah](https://github.com/thaJeztah) in [#​350](cncf-tags/container-device-interface#350) - specs-go: fix benchmark compatibility with go1.19 by [@​thaJeztah](https://github.com/thaJeztah) in [#​353](cncf-tags/container-device-interface#353) - pkg/cdi: fix flaky TestRefreshCache by [@​thaJeztah](https://github.com/thaJeztah) in [#​355](cncf-tags/container-device-interface#355) - ci: test against oldest supported, oldstable, and stable Go versions by [@​thaJeztah](https://github.com/thaJeztah) in [#​351](cncf-tags/container-device-interface#351) - pkg/cdi: TestRefreshCache: consolidate cache state checks by [@​thaJeztah](https://github.com/thaJeztah) in [#​357](cncf-tags/container-device-interface#357) - build(deps): bump actions/checkout from 7.0.0 to 7.0.1 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​349](cncf-tags/container-device-interface#349) - remove "sigs.k8s.io/yaml" dependency by [@​thaJeztah](https://github.com/thaJeztah) in [#​340](cncf-tags/container-device-interface#340) - build(deps): bump actions/setup-go from 6.4.0 to 7.0.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​348](cncf-tags/container-device-interface#348) - build(deps): bump golangci/golangci-lint-action from 9.2.1 to 9.3.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​346](cncf-tags/container-device-interface#346) - build(deps): bump codespell-project/actions-codespell from 2.1 to 2.2 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​347](cncf-tags/container-device-interface#347) - pkg/cdi: fix, and cleanup some locks, and use RWMutex by [@​thaJeztah](https://github.com/thaJeztah) in [#​345](cncf-tags/container-device-interface#345) - update minimum go version to go1.23 and modernize some code by [@​thaJeztah](https://github.com/thaJeztah) in [#​354](cncf-tags/container-device-interface#354) - chore(deps): github.com/fsnotify/fsnotify v1.7.0 by [@​thaJeztah](https://github.com/thaJeztah) in [#​359](cncf-tags/container-device-interface#359) - pkg/cdi: clean up watcher lifecycle handling and simplify refresh logic by [@​thaJeztah](https://github.com/thaJeztah) in [#​358](cncf-tags/container-device-interface#358) - pkg/cdi: fix cache refresh handling for filesystem events by [@​thaJeztah](https://github.com/thaJeztah) in [#​344](cncf-tags/container-device-interface#344) - Bump version to v1.1.1 by [@​elezar](https://github.com/elezar) in [#​361](cncf-tags/container-device-interface#361) #### New Contributors - [@​zrezke](https://github.com/zrezke) made their first contribution in [#​303](cncf-tags/container-device-interface#303) - [@​fujitatomoya](https://github.com/fujitatomoya) made their first contribution in [#​305](cncf-tags/container-device-interface#305) - [@​koenkooi](https://github.com/koenkooi) made their first contribution in [#​313](cncf-tags/container-device-interface#313) - [@​thc1006](https://github.com/thc1006) made their first contribution in [#​321](cncf-tags/container-device-interface#321) **Full Changelog**: <cncf-tags/container-device-interface@v1.1.0...v1.1.1> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - Between 12:00 AM and 03:59 AM (`* 0-3 * * *`) - Automerge - Between 12:00 AM and 03:59 AM (`* 0-3 * * *`) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC41Mi4wIiwidXBkYXRlZEluVmVyIjoiNDQuNTIuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiS2luZC9EZXBlbmRlbmN5VXBkYXRlIiwicnVuLWVuZC10by1lbmQtdGVzdHMiXX0=--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1731 Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | Type | Update | |---|---|---|---|---|---| | [connectrpc.com/connect](https://github.com/connectrpc/connect-go) | `v1.20.0` → `v1.21.0` |  |  | require | minor | | [github.com/docker/cli](https://github.com/docker/cli) | `v29.7.2+incompatible` → `v29.8.0+incompatible` |  |  | require | minor | | [github.com/moby/moby/api](https://github.com/moby/moby) | `v1.55.0` → `v1.56.0` |  |  | require | minor | | [github.com/moby/moby/client](https://github.com/moby/moby) | `v0.5.1` → `v0.6.0` |  |  | require | minor | | [golang.org/x/net](https://pkg.go.dev/golang.org/x/net) | [`v0.58.0` → `v0.59.0`](https://cs.opensource.google/go/x/net/+/refs/tags/v0.58.0...refs/tags/v0.59.0) |  |  | require | minor | | [golang.org/x/sync](https://pkg.go.dev/golang.org/x/sync) | [`v0.22.0` → `v0.23.0`](https://cs.opensource.google/go/x/sync/+/refs/tags/v0.22.0...refs/tags/v0.23.0) |  |  | require | minor | | [golang.org/x/sys](https://pkg.go.dev/golang.org/x/sys) | [`v0.47.0` → `v0.48.0`](https://cs.opensource.google/go/x/sys/+/refs/tags/v0.47.0...refs/tags/v0.48.0) |  |  | require | minor | | [golang.org/x/term](https://pkg.go.dev/golang.org/x/term) | [`v0.45.0` → `v0.46.0`](https://cs.opensource.google/go/x/term/+/refs/tags/v0.45.0...refs/tags/v0.46.0) |  |  | require | minor | | [golang.org/x/text](https://pkg.go.dev/golang.org/x/text) | [`v0.41.0` → `v0.42.0`](https://cs.opensource.google/go/x/text/+/refs/tags/v0.41.0...refs/tags/v0.42.0) |  |  | require | minor | | golang.org/x/vuln | `v1.7.0` → `v1.8.0` |  |  | | minor | | [node](https://github.com/nodejs/node) | `be23f54` → `6dac556` | | | | digest | | [node](https://github.com/nodejs/node) | `ba849c6` → `2fe369e` | | | | digest | | [tags.cncf.io/container-device-interface](https://github.com/cncf-tags/container-device-interface) | `v1.1.0` → `v1.1.1` |  |  | require | patch | --- ### Release Notes <details> <summary>connectrpc/connect-go (connectrpc.com/connect)</summary> ### [`v1.21.0`](https://github.com/connectrpc/connect-go/releases/tag/v1.21.0) [Compare Source](connectrpc/connect-go@v1.20.0...v1.21.0) #### What's Changed > \[!IMPORTANT] > > This release adds a security-related feature for servers. The new handler option [`WithRequestGate`](https://pkg.go.dev/connectrpc.com/connect#WithRequestGate) runs after the request headers are available and before any message is received. Use this new option to register checks (e.g. authentication) that should happen before the request is decompressed or unmarshaled, and before any interceptors are run. See the [documentation for details](https://connectrpc.com/docs/go/interceptors/#authentication). ##### Governance - Add pkwarren as a maintainer by [@​bufdev](https://github.com/bufdev) in [#​929](connectrpc/connect-go#929) 🎉 ##### Enhancements - Add WithRequestGate handler option by [@​emcfarlane](https://github.com/emcfarlane) in [#​962](connectrpc/connect-go#962) - Create release binary for protoc-gen-connect-go by [@​emcfarlane](https://github.com/emcfarlane) in [#​966](connectrpc/connect-go#966) ##### Bugfixes - Fix issue with user-agent getting inappropriately injected into request headers by [@​jhump](https://github.com/jhump) in [#​934](connectrpc/connect-go#934) - Fix client streaming operations blocking indefinitely after context cancellation by [@​haru0017](https://github.com/haru0017) in [#​937](connectrpc/connect-go#937) - Fix flaky HTTP2 testcase assertion by [@​emcfarlane](https://github.com/emcfarlane) in [#​940](connectrpc/connect-go#940) - Fix data race and connection leak in duplexHTTPCall by [@​emcfarlane](https://github.com/emcfarlane) in [#​938](connectrpc/connect-go#938) - Fix off-by-one in WithHTTPGetMaxURLSize URL length check by [@​fchimpan](https://github.com/fchimpan) in [#​955](connectrpc/connect-go#955) - Fix connect.WithGRPC typo in the missing client option error by [@​NotAFlightRisk](https://github.com/NotAFlightRisk) in [#​956](connectrpc/connect-go#956) - Only send a 304 when the request was a GET by [@​NotAFlightRisk](https://github.com/NotAFlightRisk) in [#​957](connectrpc/connect-go#957) - Fix panic in stream Spec and Peer when client construction failed by [@​NotAFlightRisk](https://github.com/NotAFlightRisk) in [#​959](connectrpc/connect-go#959) - Fix dropped headers on errStreamingClientConn by [@​mohit-bhandari45](https://github.com/mohit-bhandari45) in [#​964](connectrpc/connect-go#964) #### New Contributors - [@​haru0017](https://github.com/haru0017) made their first contribution in [#​937](connectrpc/connect-go#937) - [@​dongjiang1989](https://github.com/dongjiang1989) made their first contribution in [#​945](connectrpc/connect-go#945) - [@​fchimpan](https://github.com/fchimpan) made their first contribution in [#​955](connectrpc/connect-go#955) - [@​NotAFlightRisk](https://github.com/NotAFlightRisk) made their first contribution in [#​956](connectrpc/connect-go#956) - [@​mohit-bhandari45](https://github.com/mohit-bhandari45) made their first contribution in [#​964](connectrpc/connect-go#964) **Full Changelog**: <connectrpc/connect-go@v1.20.0...v1.21.0> </details> <details> <summary>docker/cli (github.com/docker/cli)</summary> ### [`v29.8.0+incompatible`](docker/cli@v29.7.2...v29.8.0) [Compare Source](docker/cli@v29.7.2...v29.8.0) </details> <details> <summary>moby/moby (github.com/moby/moby/client)</summary> ### [`v0.6.0`](moby/moby@v0.5.1...v0.6.0) [Compare Source](moby/moby@v0.5.1...v0.6.0) </details> <details> <summary>cncf-tags/container-device-interface (tags.cncf.io/container-device-interface)</summary> ### [`v1.1.1`](https://github.com/cncf-tags/container-device-interface/releases/tag/v1.1.1) [Compare Source](cncf-tags/container-device-interface@v1.1.0...v1.1.1) #### What's Changed - spec: Fix comment to reference containerEdits field by [@​zrezke](https://github.com/zrezke) in [#​303](cncf-tags/container-device-interface#303) - cdi: inject mount UID/GID mappings if user NS is in use. by [@​klihub](https://github.com/klihub) in [#​288](cncf-tags/container-device-interface#288) - cdi,SPECS.md: allow empty cgroup permissions. by [@​klihub](https://github.com/klihub) in [#​301](cncf-tags/container-device-interface#301) - .github: bump golangci-lint to v2.9.0. by [@​klihub](https://github.com/klihub) in [#​307](cncf-tags/container-device-interface#307) - add local build and install procedure in README.md. by [@​fujitatomoya](https://github.com/fujitatomoya) in [#​305](cncf-tags/container-device-interface#305) - Revert to default spec dirs if none are specified by [@​elezar](https://github.com/elezar) in [#​310](cncf-tags/container-device-interface#310) - SPEC.md: fix a few typos/clarify a sentence. by [@​klihub](https://github.com/klihub) in [#​312](cncf-tags/container-device-interface#312) - add beginner's tutorial to see how CDI works. by [@​fujitatomoya](https://github.com/fujitatomoya) in [#​311](cncf-tags/container-device-interface#311) - Makefile: add GO\_EXTRAFLAGS to go build call by [@​koenkooi](https://github.com/koenkooi) in [#​313](cncf-tags/container-device-interface#313) - Remove runtime-tools dependency by [@​elezar](https://github.com/elezar) in [#​317](cncf-tags/container-device-interface#317) - schema: add validation for top-level container edits by [@​marquiz](https://github.com/marquiz) in [#​323](cncf-tags/container-device-interface#323) - parser: guard single-character vendor and class names against a slice-bounds panic by [@​thc1006](https://github.com/thc1006) in [#​321](cncf-tags/container-device-interface#321) - chore(deps): replace deprecated gopkg.in/yaml.v3 for go.yaml.in/yaml/v3 by [@​thaJeztah](https://github.com/thaJeztah) in [#​328](cncf-tags/container-device-interface#328) - schema: make validation error private by [@​thaJeztah](https://github.com/thaJeztah) in [#​329](cncf-tags/container-device-interface#329) - pkg/cdi: stop embedding Cache mutex by [@​thaJeztah](https://github.com/thaJeztah) in [#​335](cncf-tags/container-device-interface#335) - build(deps): bump actions/stale from 10 to 11 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​327](cncf-tags/container-device-interface#327) - specs-go: add test coverage by [@​thaJeztah](https://github.com/thaJeztah) in [#​332](cncf-tags/container-device-interface#332) - replace strings.Split for strings.Cut by [@​thaJeztah](https://github.com/thaJeztah) in [#​336](cncf-tags/container-device-interface#336) - schema, validation: minor fixes and modernization by [@​thaJeztah](https://github.com/thaJeztah) in [#​330](cncf-tags/container-device-interface#330) - pkg/cdi: deprecate ErrStopScan and use os.ReadDir for scanning Spec directories by [@​thaJeztah](https://github.com/thaJeztah) in [#​339](cncf-tags/container-device-interface#339) - Bump actions/checkout from 6 to 7 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​318](cncf-tags/container-device-interface#318) - pkg/cdi: synchronize access to specDirs by [@​thaJeztah](https://github.com/thaJeztah) in [#​337](cncf-tags/container-device-interface#337) - schema: migrate to github.com/santhosh-tekuri/jsonschema/v6 by [@​thaJeztah](https://github.com/thaJeztah) in [#​331](cncf-tags/container-device-interface#331) - pkg/cdi: fix deprecations, add doc-links and "go fix" by [@​thaJeztah](https://github.com/thaJeztah) in [#​338](cncf-tags/container-device-interface#338) - internal/validation/k8s: remove unused validation helpers by [@​thaJeztah](https://github.com/thaJeztah) in [#​334](cncf-tags/container-device-interface#334) - specs-go: remove x/mod semver dependency by [@​thaJeztah](https://github.com/thaJeztah) in [#​333](cncf-tags/container-device-interface#333) - chore(deps): github.com/stretchr/testify v1.12.1 by [@​thaJeztah](https://github.com/thaJeztah) in [#​342](cncf-tags/container-device-interface#342) - ci: update golangci-lint to v2.13, and fix linting by [@​thaJeztah](https://github.com/thaJeztah) in [#​352](cncf-tags/container-device-interface#352) - ci: apply zizmor hardening fixes by [@​thaJeztah](https://github.com/thaJeztah) in [#​350](cncf-tags/container-device-interface#350) - specs-go: fix benchmark compatibility with go1.19 by [@​thaJeztah](https://github.com/thaJeztah) in [#​353](cncf-tags/container-device-interface#353) - pkg/cdi: fix flaky TestRefreshCache by [@​thaJeztah](https://github.com/thaJeztah) in [#​355](cncf-tags/container-device-interface#355) - ci: test against oldest supported, oldstable, and stable Go versions by [@​thaJeztah](https://github.com/thaJeztah) in [#​351](cncf-tags/container-device-interface#351) - pkg/cdi: TestRefreshCache: consolidate cache state checks by [@​thaJeztah](https://github.com/thaJeztah) in [#​357](cncf-tags/container-device-interface#357) - build(deps): bump actions/checkout from 7.0.0 to 7.0.1 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​349](cncf-tags/container-device-interface#349) - remove "sigs.k8s.io/yaml" dependency by [@​thaJeztah](https://github.com/thaJeztah) in [#​340](cncf-tags/container-device-interface#340) - build(deps): bump actions/setup-go from 6.4.0 to 7.0.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​348](cncf-tags/container-device-interface#348) - build(deps): bump golangci/golangci-lint-action from 9.2.1 to 9.3.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​346](cncf-tags/container-device-interface#346) - build(deps): bump codespell-project/actions-codespell from 2.1 to 2.2 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​347](cncf-tags/container-device-interface#347) - pkg/cdi: fix, and cleanup some locks, and use RWMutex by [@​thaJeztah](https://github.com/thaJeztah) in [#​345](cncf-tags/container-device-interface#345) - update minimum go version to go1.23 and modernize some code by [@​thaJeztah](https://github.com/thaJeztah) in [#​354](cncf-tags/container-device-interface#354) - chore(deps): github.com/fsnotify/fsnotify v1.7.0 by [@​thaJeztah](https://github.com/thaJeztah) in [#​359](cncf-tags/container-device-interface#359) - pkg/cdi: clean up watcher lifecycle handling and simplify refresh logic by [@​thaJeztah](https://github.com/thaJeztah) in [#​358](cncf-tags/container-device-interface#358) - pkg/cdi: fix cache refresh handling for filesystem events by [@​thaJeztah](https://github.com/thaJeztah) in [#​344](cncf-tags/container-device-interface#344) - Bump version to v1.1.1 by [@​elezar](https://github.com/elezar) in [#​361](cncf-tags/container-device-interface#361) #### New Contributors - [@​zrezke](https://github.com/zrezke) made their first contribution in [#​303](cncf-tags/container-device-interface#303) - [@​fujitatomoya](https://github.com/fujitatomoya) made their first contribution in [#​305](cncf-tags/container-device-interface#305) - [@​koenkooi](https://github.com/koenkooi) made their first contribution in [#​313](cncf-tags/container-device-interface#313) - [@​thc1006](https://github.com/thc1006) made their first contribution in [#​321](cncf-tags/container-device-interface#321) **Full Changelog**: <cncf-tags/container-device-interface@v1.1.0...v1.1.1> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - Between 12:00 AM and 03:59 AM, only on Monday (`* 0-3 * * 1`) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTEuMiIsInVwZGF0ZWRJblZlciI6IjQzLjE5MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://gitea.com/gitea/runner/pulls/1223 Reviewed-by: bircni <bircni@icloud.com> Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
pkg/cdi: simplify restoration of removed directory watches
Handle removal of watched Spec directories separately from restoring
missing watches.
Previously update() accepted an optional removed directory and marked it
as unwatched only after attempting to restore other missing watches. This
required callers to distinguish between normal updates and directory
removal, and caused update() to serve two separate purposes.
Add markRemoved() to update the watch state when fsnotify reports that a
watched directory was removed, then call update() unconditionally to
restore any watches that are currently missing. This also allows a
directory that was removed and recreated concurrently to have its watch
restored immediately.
This keeps update() focused on reconciling missing watches and removes
the special-case removed-directory argument.
pkg/cdi: watch for Create events on all platforms
Include fsnotify.Create in the event mask on all platforms instead of only
on macOS.
Spec files can be written atomically by creating a temporary file and
renaming it into place. On Linux, fsnotify reports the destination of such
a rename as a Create event. Without watching Create events, the cache may
miss the new Spec and only refresh because of an unrelated event for the
temporary file.
Watching Create events directly ensures that newly created or atomically
replaced Spec files trigger a cache refresh on all platforms.
pkg/cdi: handle fsnotify operations as a bitmask
fsnotify.Event.Opis a bitmask and can contain multiple operations, but thewatcher compared it directly against individual operation values.
As a result, combined events could bypass operation-specific handling, such as
filtering writes and creates by file extension or detecting removal of a
watched directory.
Mask the operations we are interested in and test the individual bits instead.
pkg/cdi: ignore unrelated filesystem events
The watcher filtered write and create events by file extension, but rename
and remove events for unrelated files would still trigger a refresh of the
CDI cache.
Apply the same Spec-file filtering to all relevant filesystem events, while
still processing events for configured Spec directories themselves.
This avoids unnecessary rescans when non-Spec files in watched directories are
renamed or removed, without interfering with handling of removed Spec
directories.