-
-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: docker backend should not close 'engine.Tail' result #1616
Conversation
Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
Codecov ReportPatch coverage has no change and project coverage change:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #1616 +/- ##
==========================================
- Coverage 40.64% 40.59% -0.05%
==========================================
Files 169 169
Lines 11083 11084 +1
==========================================
- Hits 4505 4500 -5
- Misses 6287 6293 +6
Partials 291 291
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
…-ci#1616) Closes woodpecker-ci#1615 The error described in woodpecker-ci#1615 is happening because `Tail` method of the docker backend closes the instance of `io.ReadCloser` it returns in `defer` function. As a result anything that try to read data returned by `Tail` method eventually will attempt to read from closes reader and get an error: https://github.com/woodpecker-ci/woodpecker/blob/2171212c5a31bfffc8f882716bdd503c65413eee/pipeline/backend/docker/docker.go#L229 The fix is just don't close returned reader and let the consumer of `Tail` method do it. Good thing is that `Tail` is used only in one place and reader is correctly closed: https://github.com/woodpecker-ci/woodpecker/blob/2171212c5a31bfffc8f882716bdd503c65413eee/pipeline/pipeline.go#L231-L237 Example of `woodpecker exec` output using pipeline from woodpecker-ci#1615 with the fix: ``` woodpecker exec .woodpecker.yaml [step1:L0:0s] + echo step1 [step1:L1:0s] step1 [step2:L0:0s] + echo step2 [step2:L1:0s] step2 ``` Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
backport -> #1620 |
) Backport #1616 Close #1615 The error described in #1615 is happening because `Tail` method of the docker backend closes the instance of `io.ReadCloser` it returns in `defer` function. As a result anything that try to read data returned by `Tail` method eventually will attempt to read from closes reader and get an error: https://github.com/woodpecker-ci/woodpecker/blob/2171212c5a31bfffc8f882716bdd503c65413eee/pipeline/backend/docker/docker.go#L229 The fix is just don't close returned reader and let the consumer of `Tail` method do it. Good thing is that `Tail` is used only in one place and reader is correctly closed: https://github.com/woodpecker-ci/woodpecker/blob/2171212c5a31bfffc8f882716bdd503c65413eee/pipeline/pipeline.go#L231-L237 Example of `woodpecker exec` output using pipeline from #1615 with the fix: ``` woodpecker exec .woodpecker.yaml [step1:L0:0s] + echo step1 [step1:L1:0s] step1 [step2:L0:0s] + echo step2 [step2:L1:0s] step2 ``` Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> Co-authored-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
Closes #1615
The error described in #1615 is happening because
Tail
method of the docker backend closes the instance ofio.ReadCloser
it returns indefer
function. As a result anything that try to read data returned byTail
method eventually will attempt to read from closes reader and get an error:woodpecker/pipeline/backend/docker/docker.go
Line 229 in 2171212
The fix is just don't close returned reader and let the consumer of
Tail
method do it. Good thing is thatTail
is used only in one place and reader is correctly closed:woodpecker/pipeline/pipeline.go
Lines 231 to 237 in 2171212
Example of
woodpecker exec
output using pipeline from #1615 with the fix: