Skip to content

Commit ce76903

Browse files
CopilotMikeZappa87
andcommitted
Improve error log messages to provide better context for troubleshooting
Co-authored-by: MikeZappa87 <61716064+MikeZappa87@users.noreply.github.com>
1 parent 632dd28 commit ce76903

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cns/fsnotify/fsnotify.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,20 @@ func (w *watcher) releaseAll(ctx context.Context) {
6060
filepath := filepath.Join(w.path, containerID)
6161
file, err := os.Open(filepath)
6262
if err != nil {
63-
w.log.Error("failed to open file", zap.Error(err))
63+
w.log.Error("failed to open container file for IP release",
64+
zap.String("filepath", filepath),
65+
zap.String("containerID", containerID),
66+
zap.Error(err))
6467
continue
6568
}
6669

6770
data, errReadingFile := io.ReadAll(file)
6871
file.Close()
6972
if errReadingFile != nil {
70-
w.log.Error("failed to read file content", zap.Error(errReadingFile))
73+
w.log.Error("failed to read container file content for IP release",
74+
zap.String("filepath", filepath),
75+
zap.String("containerID", containerID),
76+
zap.Error(errReadingFile))
7177
continue
7278
}
7379
podInterfaceID := string(data)
@@ -80,7 +86,10 @@ func (w *watcher) releaseAll(ctx context.Context) {
8086
w.log.Info("successfully released IP for missed delete", zap.String("containerID", containerID))
8187
delete(w.pendingDelete, containerID)
8288
if err := removeFile(containerID, w.path); err != nil {
83-
w.log.Error("failed to remove file for missed delete", zap.Error(err))
89+
w.log.Error("failed to remove container file after IP release",
90+
zap.String("containerID", containerID),
91+
zap.String("path", w.path),
92+
zap.Error(err))
8493
}
8594
}
8695
}

0 commit comments

Comments
 (0)