pulumi/sdk/go/common
Thomas Gummerer f6f2c5db1c
fix race condition in tail better (#18066)
In https://github.com/pulumi/pulumi/pull/18044 we vendored the
nxadm/tail library and pulled in a couple of changes from upstream to
avoid race conditions.

However the changes from upstream were not sufficient. Namely, one of
the changes was to try and avoid exiting early if tail is meant to stop
at the next EOF. It did so by setting the earlyExitChan to `nil` if tail
was requested to shut down with a stopAtEOF error. However it is
possible that stopAtEOF is written to the earlyExitChan after we checked
`tail.Err()`, but before we get to the select.

In that case we can still get an early exit on EOF, which we don't want.
Move the check for the stopAtEOF error into the earlyExitChan case. At
this point tail.Err() is guaranteed to be set correctly, if the user
requested a stop at eof.

Also fix a separate race in the test, where the test called `Stop()`
twice, which was incorrect and unnecessary.

(This unflaked the test `TestFollowUntilEof` locally for me. Using `go
test -run TestFollowUntilEof\$ -count 10000 .` would fail pretty
consistently after a couple of time max. With this change running it in
a loop doesn't seem to break it anymore)

This requires no separate changelog entry since
https://github.com/pulumi/pulumi/pull/18044 was not released yet.

---------

Co-authored-by: Will Jones <will@sacharissa.co.uk>
2024-12-18 12:10:53 +00:00
..
apitype Move EscEnvironmentMetadata to apitype (#17720) 2024-11-08 14:32:13 +00:00
constant Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
diag allow InputPropertyErrors from Calls (#17567) 2024-11-07 09:56:04 +00:00
encoding all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
env Enable Copilot link by default (#17293) 2024-09-20 01:15:16 +00:00
promise Add tests to sdk/go/common/promise for coverage (#17197) 2024-09-08 21:07:08 +00:00
resource Log Plugin stdout & stderr as debug (instead of info) (#17943) 2024-12-12 18:09:19 +00:00
slice Nit: Use slice.Prealloc in slice.Map and slice.MapError (#17631) 2024-10-29 15:35:55 +00:00
tail fix race condition in tail better (#18066) 2024-12-18 12:10:53 +00:00
testing Move `sdk/go/common/tools/path` to `pkg` (#17898) 2024-12-02 17:13:30 +00:00
tokens Enable some more linting rules (#17456) 2024-10-03 17:37:13 +00:00
util cmdutil/profile: do not defer in loop (#17581) 2024-12-10 15:10:43 +00:00
version move pkg/version -> sdk/go/common/version 2020-03-18 15:25:25 -07:00
workspace Update golangci-lint (#17972) 2024-12-10 11:50:38 +00:00