Skip to content

Fix panic on PatchTrace execution

Tomasz Maczukin requested to merge fix-panic-on-patch-trace into master

What does this MR do?

Prevents a panic raised in some cases when PatchTrace is executed.

Why was this MR needed?

With !886 (merged) we've create a regression. n.doRaw in some cases (e.g. network problems between Runner and GitLab) may return an error and nil instead of response. Currently this ends with:

May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com gitlab-runner[881]: panic: runtime error: invalid memory address or nil pointer dereference
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com gitlab-runner[881]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x8fcf30]
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com gitlab-runner[881]: goroutine 91281 [running]:
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com gitlab-runner[881]: gitlab.com/gitlab-org/gitlab-runner/network.(*GitLabClient).PatchTrace(0xc4203c5900, 0xc42018f8a0, 0x15, 0x96, 0x0, 0xf, 0xc42018f9c0, 0x13, 0xc4203fc780, 0x1e, ...)
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com gitlab-runner[881]: #011/builds/gitlab-org/gitlab-runner/.gopath/src/gitlab.com/gitlab-org/gitlab-runner/network/gitlab.go:342 +0x4d0
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com gitlab-runner[881]: gitlab.com/gitlab-org/gitlab-runner/network.(*clientJobTrace).incrementalUpdate(0xc422933180, 0xc420f89a40)
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com gitlab-runner[881]: #011/builds/gitlab-org/gitlab-runner/.gopath/src/gitlab.com/gitlab-org/gitlab-runner/network/trace.go:220 +0x424
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com gitlab-runner[881]: gitlab.com/gitlab-org/gitlab-runner/network.(*clientJobTrace).watch(0xc422933180)
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com gitlab-runner[881]: #011/builds/gitlab-org/gitlab-runner/.gopath/src/gitlab.com/gitlab-org/gitlab-runner/network/trace.go:306 +0xda
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com gitlab-runner[881]: created by gitlab.com/gitlab-org/gitlab-runner/network.(*clientJobTrace).start
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com gitlab-runner[881]: #011/builds/gitlab-org/gitlab-runner/.gopath/src/gitlab.com/gitlab-org/gitlab-runner/network/trace.go:136 +0x1a9
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com systemd[1]: gitlab-runner.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com systemd[1]: gitlab-runner.service: Unit entered failed state.
May 18 08:49:29 gitlab-shared-runners-manager-1.gitlab.com systemd[1]: gitlab-runner.service: Failed with result 'exit-code'.

This MR fixes this regression.

Are there points in the code the reviewer needs to double check?

Does this MR meet the acceptance criteria?

  • Documentation created/updated
  • Tests
    • Added for this feature/bug
    • All builds are passing
  • Branch has no merge conflicts with master (if you do - rebase it please)

What are the relevant issue numbers?

Merge request reports