logmon: Workaround golang/go#29119

There's a bug in go1.11 that causes some io operations on windows to
return incorrect errors for some cases when Stat-ing files. To avoid
upgrading to go1.12 in a point release, here we loosen up the cases
where we will attempt to create fifos, and add some logging of
underlying stat errors to help with debugging.
This commit is contained in:
Danielle Lancashire 2019-07-22 17:49:19 +02:00
parent dd6f55f33f
commit 1bcbbbfbe6
No known key found for this signature in database
GPG Key ID: 8D65584EF3DDF91B
1 changed files with 3 additions and 1 deletions

View File

@ -204,7 +204,8 @@ func newLogRotatorWrapper(path string, logger hclog.Logger, rotator *logging.Fil
var openFn func() (io.ReadCloser, error)
var err error
if _, ferr := os.Stat(path); os.IsNotExist(ferr) {
_, serr := os.Stat(path)
if serr != nil {
openFn, err = fifo.CreateAndRead(path)
} else {
openFn = func() (io.ReadCloser, error) {
@ -213,6 +214,7 @@ func newLogRotatorWrapper(path string, logger hclog.Logger, rotator *logging.Fil
}
if err != nil {
logger.Error("Failed to create FIFO", "stat_error", serr, "create_err", err)
return nil, fmt.Errorf("failed to create fifo for extracting logs: %v", err)
}