1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-28 02:37:11 +00:00

pkg/util: migrate to structured logging

We gRPC logging interface is not compatible with structured logging so
grpcLogger is left intact.
This commit is contained in:
Markus Lehtonen 2023-05-12 14:55:14 +03:00
parent 64d5af016e
commit 4947ebf336
2 changed files with 8 additions and 8 deletions

View file

@ -94,9 +94,9 @@ func (w *FsWatcher) add(names ...string) error {
for p := name; ; p = filepath.Dir(p) {
if _, ok := w.paths[p]; !ok {
if err := w.Add(p); err != nil {
klog.V(1).Infof("failed to add fsnotify watch for %q: %v", p, err)
klog.V(1).ErrorS(err, "failed to add fsnotify watch", "path", p)
} else {
klog.V(1).Infof("added fsnotify watch %q", p)
klog.V(1).InfoS("added fsnotify watch", "path", p)
added = true
}
@ -124,14 +124,14 @@ func (w *FsWatcher) watch() {
case e, ok := <-w.Watcher.Events:
// Watcher has been closed
if !ok {
klog.Infof("watcher closed")
klog.InfoS("watcher closed")
return
}
// If any of our paths change
name := filepath.Clean(e.Name)
if _, ok := w.paths[filepath.Clean(name)]; ok {
klog.V(2).Infof("fsnotify %s event in %q detected", e, name)
klog.V(2).InfoS("fsnotify event detected", "path", name, "fsNotifyEvent", e)
// Rate limiter. In certain filesystem operations we get
// numerous events in quick succession
@ -141,15 +141,15 @@ func (w *FsWatcher) watch() {
case e, ok := <-w.Watcher.Errors:
// Watcher has been closed
if !ok {
klog.Infof("watcher closed")
klog.InfoS("watcher closed")
return
}
klog.Warningf("fswatcher error event detected: %v", e)
klog.ErrorS(e, "fswatcher error event detected")
case <-ratelimiter:
// Blindly remove existing watch and add a new one
if err := w.reset(w.names...); err != nil {
klog.Errorf("%v, re-trying in 60 seconds...", err)
klog.ErrorS(err, "re-trying in 60 seconds")
ratelimiter = time.After(60 * time.Second)
}

View file

@ -91,7 +91,7 @@ func getHugepagesBytes(path string) (MemoryResourceInfo, error) {
for _, entry := range entries {
split := strings.SplitN(entry.Name(), "-", 2)
if len(split) != 2 || split[0] != "hugepages" {
klog.Warningf("malformed hugepages entry %q", entry.Name())
klog.InfoS("malformed hugepages entry", "hugepagesEntry", entry.Name())
continue
}