Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

core/runner: Fix server panic when runner is forgotten #3756

Merged
merged 2 commits into from Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3756.txt
@@ -0,0 +1,3 @@
```release-note:bug
core/runner: Server no longer panics when a runner stopped after it is forgotten.
```
3 changes: 1 addition & 2 deletions internal/server/boltdbstate/runner.go
Expand Up @@ -304,8 +304,7 @@ func (s *State) runnerSetAdoptionState(
func (s *State) runnerOffline(dbTxn *bolt.Tx, memTxn *memdb.Txn, id string) error {
r, err := s.runnerById(dbTxn, id)
if status.Code(err) == codes.NotFound {
r = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the NotFound case when r is nil, won't the switch case on 323 still panic because r.Kind? Should we be returning here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I didn't double check to make sure that r.Kind was seeded with a default when initializing the struct and sure enough it doesn't.

Instead of initializing a blank runner struct i've short-circuited and returned nil in 83f900d76 as even if we get a NotFound error there isn't a runner we would need to delete, thus we can skip the rest of the function.

err = nil
return nil
}
if err != nil {
return err
Expand Down