-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Downgrade error log lines on Windows filesystem access issues (#907)
- Loading branch information
Showing
5 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package utils | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
"strings" | ||
|
||
"github.com/rogpeppe/go-internal/robustio" | ||
) | ||
|
||
// IsEphemeralOrFileClosed checks if the error is an ephemeral error or if the file is already closed. This is useful | ||
// on certain file systems (e.g. on Windows) where in practice reading a file can result in ephemeral errors | ||
// (e.g. due to antivirus scans) or if the file appears as closed when being removed or rotated. | ||
func IsEphemeralOrFileClosed(err error) bool { | ||
return robustio.IsEphemeralError(err) || | ||
errors.Is(os.ErrClosed, err) || | ||
// The above errors.Is(os.ErrClosedm, err) condition doesn't always capture the 'file already closed' error on | ||
// Windows. Check the error message as well. | ||
// Inspired by https://github.com/grafana/loki/blob/987e551f9e21b9a612dd0b6a3e60503ce6fe13a8/clients/cmd/docker-driver/driver.go#L145 | ||
strings.Contains(err.Error(), "file already closed") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters