woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.32k stars 373 forks source link

server crashes when trying to select log that doesn't exist yet #1063

Closed JulianGro closed 2 years ago

JulianGro commented 2 years ago

Component

server

Describe the bug

When selecting a log that doesn't exist yet, the woodpecker-server crashes. 2022-07-31 23 43 16 ci moto9000 moe 81d54b9321b8

System Info

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"next-37146058"}

My agents are running the same version.

# docker-compose.yml
version: '3'

services:
  woodpecker-server:
    image: woodpeckerci/woodpecker-server:next
    ports:
      - 80:80
      - 443:443
      - 9000:9000
    volumes:
      - woodpecker-server-data:/var/lib/woodpecker/
    environment:
      - WOODPECKER_OPEN=true
      - WOODPECKER_HOST=https://ci.moto9000.moe
      - WOODPECKER_LETS_ENCRYPT=true
      - WOODPECKER_GITHUB=true
      - WOODPECKER_GITHUB_CLIENT=REDACTED
      - WOODPECKER_GITHUB_SECRET=REDACTED
      - WOODPECKER_AGENT_SECRET=REDACTED
      - WOODPECKER_ADMIN=REDACTED
      - WOODPECKER_REPO_OWNERS=REDACTED,REDACTED

volumes:
  woodpecker-server-data:

Additional context

Full log:

{"time":"2022-07-31T21:23:29Z","message":"LogLevel = warn"}
{"level":"warn","error":"sql: no rows in result set","time":"2022-07-31T21:24:11Z"}
{"level":"error","error":"no secret found for \"do_s3_access_key\"","time":"2022-07-31T21:27:11Z","message":"paramsToEnv"}
{"level":"error","error":"no secret found for \"do_s3_access_key\"","time":"2022-07-31T21:27:11Z","message":"paramsToEnv"}
{"level":"warn","error":"sql: no rows in result set","time":"2022-07-31T21:28:10Z"}
{"level":"warn","error":"sql: no rows in result set","time":"2022-07-31T21:28:31Z"}
{"level":"warn","error":"sql: no rows in result set","time":"2022-07-31T21:28:32Z"}
{"level":"warn","error":"sql: no rows in result set","time":"2022-07-31T21:30:44Z"}
2022/07/31 21:39:20 http: TLS handshake error from 45.95.147.40:44398: acme/autocert: missing server name
{"level":"warn","error":"sql: no rows in result set","time":"2022-07-31T21:41:49Z"}
{"level":"error","error":"no secret found for \"do_s3_secret_key\"","time":"2022-07-31T21:42:12Z","message":"paramsToEnv"}
{"level":"error","error":"no secret found for \"do_s3_access_key\"","time":"2022-07-31T21:42:12Z","message":"paramsToEnv"}
{"level":"error","error":"no secret found for \"do_s3_access_key\"","time":"2022-07-31T21:42:15Z","message":"paramsToEnv"}
{"level":"error","error":"no secret found for \"do_s3_access_key\"","time":"2022-07-31T21:42:15Z","message":"paramsToEnv"}
panic: Write called after Handler finished

goroutine 904 [running]:
net/http.(*http2responseWriter).write(0xc0006ae4e0?, 0xc0007ff688?, {0x0?, 0xfdb0e0?, 0x1078160?}, {0x1137e18?, 0xc0006be188?})
    /usr/local/go/src/net/http/h2_bundle.go:6427 +0x150
net/http.(*http2responseWriter).WriteString(0xc0007ff6c0?, {0x1137e18?, 0xc0006be188?})
    /usr/local/go/src/net/http/h2_bundle.go:6420 +0x2e
io.WriteString({0x7fc8702ba0b8, 0xc0006be188}, {0x1137e18, 0x18})
    /usr/local/go/src/io/io.go:312 +0x5d
github.com/gin-gonic/gin.(*responseWriter).WriteString(0xc00040c800, {0x1137e18, 0x18})
    /woodpecker/src/github.com/woodpecker-ci/woodpecker/vendor/github.com/gin-gonic/gin/response_writer.go:85 +0x7b
io.WriteString({0x7fc8702ba078, 0xc00040c800}, {0x1137e18, 0x18})
    /usr/local/go/src/io/io.go:312 +0x5d
github.com/woodpecker-ci/woodpecker/server/api.LogStreamSSE.func2()
    /woodpecker/src/github.com/woodpecker-ci/woodpecker/server/api/stream.go:199 +0x192
created by github.com/woodpecker-ci/woodpecker/server/api.LogStreamSSE
    /woodpecker/src/github.com/woodpecker-ci/woodpecker/server/api/stream.go:179 +0x59b


### Validations

- [X] Read the [Contributing Guidelines](https://github.com/woodpecker-ci/woodpecker/blob/master/CONTRIBUTING.md).
- [X] Read the [docs](https://woodpecker-ci.org/docs/intro).
- [X] Check that there isn't [already an issue](https://github.com/woodpecker-ci/woodpecker/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A join our [Discord Chat Server](https://discord.gg/fcMQqSMXJy) or the [Matrix room](https://matrix.to/#/#woodpecker:matrix.org).
qwerty287 commented 2 years ago

This is a duplicate of #986 (even if it complains about something else, it's the same underlying issue).