Skip to content

Commit d3def6c

Browse files
authored
Merge pull request #2654 from nirs/remove-race
Suppress error if file is already deleted
2 parents 5b87d2d + 7a2bb68 commit d3def6c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/instance/stop.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ func StopForcibly(inst *store.Instance) {
9393
}
9494

9595
suffixesToBeRemoved := []string{".pid", ".sock", ".tmp"}
96-
logrus.Infof("Removing %s under %q", inst.Dir, strings.ReplaceAll(strings.Join(suffixesToBeRemoved, " "), ".", "*."))
96+
globPatterns := strings.ReplaceAll(strings.Join(suffixesToBeRemoved, " "), ".", "*.")
97+
logrus.Infof("Removing %s under %q", globPatterns, inst.Dir)
98+
9799
fi, err := os.ReadDir(inst.Dir)
98100
if err != nil {
99101
logrus.Error(err)
@@ -105,7 +107,11 @@ func StopForcibly(inst *store.Instance) {
105107
if strings.HasSuffix(path, suffix) {
106108
logrus.Infof("Removing %q", path)
107109
if err := os.Remove(path); err != nil {
108-
logrus.Error(err)
110+
if errors.Is(err, os.ErrNotExist) {
111+
logrus.Debug(err.Error())
112+
} else {
113+
logrus.Error(err)
114+
}
109115
}
110116
}
111117
}

0 commit comments

Comments
 (0)