Skip to content

Conversation

@ArangoGutierrez
Copy link
Contributor

Close the fsnotify watcher when the context is cancelled to prevent resource leaks. The watcher reference is also reset to nil to allow proper re-initialization if SetNotifyChannel is called again.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ArangoGutierrez

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 14, 2026
@netlify
Copy link

netlify bot commented Jan 14, 2026

Deploy Preview for kubernetes-sigs-nfd ready!

Name Link
🔨 Latest commit aaeca24
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-nfd/deploys/6967b6f9ffaebe00087f9198
😎 Deploy Preview https://deploy-preview-2412--kubernetes-sigs-nfd.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 14, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a resource leak by ensuring the fsnotify watcher is properly closed when the context is cancelled in the local source implementation. The fix adds a cleanup function that closes the watcher and resets its reference.

Changes:

  • Added cleanupWatcher() method to close the fsnotify watcher and reset the reference to nil
  • Modified runNotifier() to defer the cleanup function, ensuring watcher cleanup on context cancellation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Close the fsnotify watcher when the context is cancelled to prevent
resource leaks. The watcher reference is also reset to nil to allow
proper re-initialization if SetNotifyChannel is called again.

Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 14, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

source/local/local.go:334

  • The runNotifier function accesses s.fsWatcher.Events and s.fsWatcher.Errors without holding the mutex lock. Since cleanupWatcher() can set s.fsWatcher to nil under the lock, there's a potential race condition where runNotifier could be reading from a nil watcher's channels after cleanup, leading to a panic. Consider holding a local reference to the watcher at the start of runNotifier before entering the select loop, or add nil checks before accessing the watcher's channels.
		case event := <-s.fsWatcher.Events:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ArangoGutierrez
Copy link
Contributor Author

/assign @marquiz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants