Remove unneeded stopping of nil Dispatcher#2897
Conversation
gotjosh
left a comment
There was a problem hiding this comment.
LGTM.
Took a while to review this one, I wasn't sure I understood why didn't we need to move this one but after a few rounds of testing and a re-read, this is safe to remove.
I think that we need to add is a way to explicitly stop all components similarly, as an example both silence and nflog maintenance are governed by the stopc but mem.NewAlerts nor Dispatcher aren't - would good to make sure all components are cleanly shutting down as we exit.
Let me know if you'd like to create a follow issue+PR to make sure we don't forget as I think this can be separate from this PR.
97012cf to
71adb5a
Compare
|
This PR just resulted from brief tourism into the AM codebase for the purpose of refreshing my memory about it :) I filed an issue (#2906), but can't promise I'll get to it myself. Now actually looking at this PR here again, I noticed that indeed, the Dispatcher is also not shut down any other way when main.go exits (only upon config reload), so the right short-term fix is probably not to remove this ineffectual line, but to fix it by wrapping the |
The function value and parameters of a defer statement are immediately evaluated, so this "disp" value is always nil, and calling Stop() on a nil dispatcher is a no-op, so this does nothing, but wrapping it in a closure that refers to "disp" fixes it. Signed-off-by: Julius Volz <julius.volz@gmail.com>
71adb5a to
649fdee
Compare
I'm happy to take it for a spin.
That also works 😄 |
|
Thanks! |
The function value and parameters of a defer statement are immediately evaluated, so this "disp" value is always nil, and calling Stop() on a nil dispatcher is a no-op, so this does nothing, but wrapping it in a closure that refers to "disp" fixes it. Signed-off-by: Julius Volz <julius.volz@gmail.com> Signed-off-by: Yijie Qin <qinyijie@amazon.com>
The function value and parameters of a defer statement are immediately
evaluated, so this "disp" value is always nil, and calling Stop() on a nil
dispatcher is a no-op, so this does nothing, but is confusing.
Signed-off-by: Julius Volz julius.volz@gmail.com