Skip to content

Commit

Permalink
Display messages on all close errors in workunitbase (#1192)
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-at-redhat authored Oct 24, 2024
1 parent 5312a25 commit 234c21b
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions pkg/workceptor/workunitbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ func (sfd *StatusFileData) Save(filename string) error {
}
err = sfd.saveToFile(file)
if err != nil {
_ = file.Close()
serr := file.Close()

if serr != nil {
MainInstance.nc.GetLogger().Error("Error closing %s: %s", filename, serr)
}

return err
}
Expand Down Expand Up @@ -262,7 +266,10 @@ func (sfd *StatusFileData) Load(filename string) error {
}
err = sfd.loadFromFile(file)
if err != nil {
_ = file.Close()
lerr := file.Close()
if lerr != nil {
MainInstance.nc.GetLogger().Error("Error closing %s: %s", filename, lerr)
}

return err
}
Expand Down Expand Up @@ -389,11 +396,17 @@ func (bwu *BaseWorkUnit) MonitorLocalStatus() {
err := bwu.watcher.Add(statusFile)
if err == nil {
defer func() {
_ = bwu.watcher.Close()
werr := bwu.watcher.Close()
if werr != nil {
bwu.w.nc.GetLogger().Error("Error closing %s: %s", statusFile, err)
}
}()
watcherEvents = bwu.watcher.EventChannel()
} else {
_ = bwu.watcher.Close()
werr := bwu.watcher.Close()
if werr != nil {
bwu.w.nc.GetLogger().Error("Error closing %s: %s", statusFile, err)
}
bwu.watcher = nil
}
}
Expand Down

0 comments on commit 234c21b

Please sign in to comment.