Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfd-topology-updater: fix wrong kubelet_internal_checkpoint path and compare basename to full path #1167

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pkg/nfd-topology-updater/kubeletnotifier/kubeletnotifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package kubeletnotifier

import (
"fmt"
"path"
"time"

"k8s.io/apimachinery/pkg/util/sets"
Expand All @@ -31,6 +32,8 @@ type EventType string
const (
IntervalBased EventType = "intervalBased"
FSUpdate EventType = "fsUpdate"

devicePluginsDirName = "device-plugins"
Copy link
Contributor

@Tal-or Tal-or Apr 23, 2023

Choose a reason for hiding this comment

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

Maybe it is better to change Kubelet-state-dir to a slice instead of string and specifies the device-plugins as part of the configuration.
This allows greater flexibility.
Then in the configuration we'll specify
--kubelet-state-dir=/var/lib/kubelet --kubelet-state-dir=/var/lib/kubelet/device-plugins

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the idea of allowing passing more than one dir here but kubelet_checkpoint_internal is hardcoded as a default file to watch and we are failing in doing it since we setup watchers for wrong directory. We should either fix what we have right now or allow flexibility in specifying files to watch not dirs :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Switching to files sounds good to me but maybe it deserves a separate PR and the current implementation and fix are good enough for this pr

)

var stateFiles = sets.NewString(
Expand All @@ -51,7 +54,8 @@ type Info struct {
}

func New(sleepInterval time.Duration, dest chan<- Info, kubeletStateDir string) (*Notifier, error) {
ch, err := createFSWatcherEvent([]string{kubeletStateDir})
devicePluginsDir := path.Join(kubeletStateDir, devicePluginsDirName)
ch, err := createFSWatcherEvent([]string{kubeletStateDir, devicePluginsDir})
if err != nil {
return nil, err
}
Expand All @@ -77,8 +81,9 @@ func (n *Notifier) Run() {
n.dest <- i

case e := <-n.fsEvent:
klog.V(5).Infof("fsnotify event from file %q: %q received", e.Name, e.Op)
if stateFiles.Has(e.Name) {
basename := path.Base(e.Name)
klog.V(5).Infof("fsnotify event from file %q: %q received", basename, e.Op)
if stateFiles.Has(basename) {
i := Info{Event: FSUpdate}
n.dest <- i
}
Expand Down