-
Notifications
You must be signed in to change notification settings - Fork 329
core/runner: Fix server panic when runner is forgotten #3756
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 💥
0e961d0
to
a83b387
Compare
r, err := s.runnerById(dbTxn, id) | ||
if status.Code(err) == codes.NotFound { | ||
r = nil |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Before this commit when Waypoint was determining whether or not to remove a Runner from boltdb it was possible for runner to be nil at the time we attempted to determine what type of Runner the Runner was. This caused the server to panic as soon as the runner became unavailable. This commit fixes the panic by checking if we received a runner from the database before determining its type. Fixes #3448
a83b387
to
a34424b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 👍🏻 🎉
Before this commit when Waypoint was determining whether or not to
remove a Runner from boltdb it was possible for runner to be nil at the
time we attempted to determine what type of Runner the Runner was. This
caused the server to panic as soon as the runner became unavailable.
This commit fixes the panic by avoiding the runner from being set to nil
by instead initializing an empty runner variable so that if a runner is
not found the type can still be determined and the runner cleaned up.
Fixes #3448