Skip to content

Commit 7a2bb68

Browse files
committed
Suppress error if file is already deleted
We have a race (time of check, time of use) when deleting a vm with --force. We first list the file in the instance dir, and then delete matching files. "ssh.sock" is consistently already deleted when we try to remove it, creating unwanted noise in the log. "ssh.sock" is probably removed by other code that may need need to remove it. To make this easy to improve we still log the event in debug level. Fixes: #2635 Signed-off-by: Nir Soffer <[email protected]>
1 parent a844d28 commit 7a2bb68

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/instance/stop.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ func StopForcibly(inst *store.Instance) {
107107
if strings.HasSuffix(path, suffix) {
108108
logrus.Infof("Removing %q", path)
109109
if err := os.Remove(path); err != nil {
110-
logrus.Error(err)
110+
if errors.Is(err, os.ErrNotExist) {
111+
logrus.Debug(err.Error())
112+
} else {
113+
logrus.Error(err)
114+
}
111115
}
112116
}
113117
}

0 commit comments

Comments
 (0)