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

Conversation

demophoon
Copy link
Contributor

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

Copy link
Contributor

@paladin-devops paladin-devops left a comment

Choose a reason for hiding this comment

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

🐛 💥

@paladin-devops paladin-devops added pr/no-changelog No automatic changelog entry required for this pull request and removed pr/no-changelog No automatic changelog entry required for this pull request labels Aug 29, 2022
@demophoon demophoon force-pushed the bug/main/forgot-my-runner-then-server-panic branch from 0e961d0 to a83b387 Compare August 29, 2022 22:31
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.

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
Copy link
Member

@briancain briancain left a comment

Choose a reason for hiding this comment

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

Nice! 👍🏻 🎉

@demophoon demophoon merged commit 2ea0ca2 into main Aug 30, 2022
@demophoon demophoon deleted the bug/main/forgot-my-runner-then-server-panic branch August 30, 2022 23:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Waypoint server panics when runner is forgotten before stopped
3 participants