fix(plugin): fix plugin family runner race condition #1824
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
If an error occurs, we send the result back to the family manager on a channel and return from the function:
As part of the return, the deferred
Stop
andRemove
lifecycle functions begin to run:Once the family manager gets the result in the result channel, it does not really care if the underlying goroutines are finished or not:
vmclarity/scanner/families/manager.go
Line 148 in 0750034
This results in a race condition, once the family manager gets all the results it expects, the program will terminate regardless of whether the plugins' Stop() and Destroy() functions have finished or not.
We need to call the
Exit
andDestroy
lifecycle functions before sending back the result.Type of Change
Checklist