Skip to content

Conversation

@simongdavies
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings January 7, 2026 22:38
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 pull request modernizes the device plugin's logging and kubelet restart detection by replacing the standard log package with k8s.io/klog/v2 and introducing fsnotify for event-based monitoring instead of polling.

Key changes:

  • Migration from standard library log to structured k8s.io/klog/v2 logging with verbosity levels
  • Introduction of fsnotify for efficient filesystem event monitoring with polling fallback
  • Enhancement of health check logic to update all devices when the underlying hypervisor device becomes unavailable

Reviewed changes

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

File Description
device-plugin/main.go Replaced all log calls with klog, added fsnotify-based kubelet restart detection with polling fallback, improved health checking to update all devices
device-plugin/go.mod Added dependencies for fsnotify v1.8.0 and klog/v2 v2.130.1
device-plugin/go.sum Added checksums for new dependencies
Comments suppressed due to low confidence (1)

device-plugin/main.go:209

  • The health check logic has a potential race condition. The p.devices slice is being read and modified without synchronization in ListAndWatch, while it could potentially be accessed from other goroutines (e.g., during Allocate calls). Although the Kubernetes device plugin framework typically serializes these calls, accessing and modifying the shared devices slice without proper synchronization could lead to data races in edge cases.
			// Check if health changed (compare against first device as representative)
			if p.devices[0].Health != newHealth {
				// Update ALL devices - they all share the same underlying hypervisor device
				for i := range p.devices {
					p.devices[i].Health = newHealth
				}
				klog.Infof("Device health changed to %s for all %d devices", newHealth, len(p.devices))
				if err := srv.Send(&pluginapi.ListAndWatchResponse{Devices: p.devices}); err != nil {
					return err
				}
			}

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

Signed-off-by: Simon Davies <[email protected]>
- Rename newHealth to health (Go naming conventions)
- Remove dead kubeletSock check (wrong directory being watched)
- Handle closed fsnotify channels with fallback to polling
- Update comment to reflect actual behavior

Signed-off-by: Simon Davies <[email protected]>
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 2 out of 3 changed files in this pull request and generated no new comments.


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

@simongdavies simongdavies merged commit 30a56f2 into main Jan 7, 2026
4 checks passed
@simongdavies simongdavies deleted the fsnotify-and-klog branch January 7, 2026 23:14
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.

1 participant