Fix error when closing logs (#2637)

Previously, *all* log streams of the pipeline were closed everytime when
a workflow is done, if you have multiple workflows, streams will be
closed multiple times.

Closes https://github.com/woodpecker-ci/woodpecker/issues/2036
This commit is contained in:
qwerty287 2023-10-24 10:44:36 +02:00 committed by GitHub
parent 31240b5771
commit a1a35eb7be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -284,13 +284,11 @@ func (s *RPC) Done(c context.Context, id string, state rpc.State) error {
// make sure writes to pubsub are non blocking (https://github.com/woodpecker-ci/woodpecker/blob/c919f32e0b6432a95e1a6d3d0ad662f591adf73f/server/logging/log.go#L9) // make sure writes to pubsub are non blocking (https://github.com/woodpecker-ci/woodpecker/blob/c919f32e0b6432a95e1a6d3d0ad662f591adf73f/server/logging/log.go#L9)
go func() { go func() {
for _, wf := range currentPipeline.Workflows { for _, step := range workflow.Children {
for _, step := range wf.Children {
if err := s.logger.Close(c, step.ID); err != nil { if err := s.logger.Close(c, step.ID); err != nil {
logger.Error().Err(err).Msgf("done: cannot close log stream for step %d", step.ID) logger.Error().Err(err).Msgf("done: cannot close log stream for step %d", step.ID)
} }
} }
}
}() }()
if err := s.notify(repo, currentPipeline); err != nil { if err := s.notify(repo, currentPipeline); err != nil {