add watchdog goroutine for docker#898
Conversation
LawnGnome
left a comment
There was a problem hiding this comment.
Generally LGTM. I'm surprised at how little code this actually was!
| } | ||
|
|
||
| func (w *WatchDog) Start() { | ||
| for _ = range w.ticker.Chan() { |
There was a problem hiding this comment.
I realised while re-reviewing this that we can't do it quite this simply — I vaguely remembered that there was some weirdness around something to do with channels, and it was that stopped Tickers are not actually closed, because… well, you can read the docs. (I honestly interpret it mostly as "because fuck you, that's why".)
This would have been OK if it was a "normal" channel that was closed when it was no longer needed. Bah.
So, two options:
- We reinstate the previous, two channel behaviour, just with a
returnon thedonecase, or - We decide we don't care about leaking a goroutine, because
srcis likely about to exit anyway.
I'm not super fussed either way. I'm sorry for forgetting the nuance until after you'd done the work!
There was a problem hiding this comment.
There's no need to apologize. This ticket has been a big learning experience with channels for me - learnt a lot from pairing with @Piszmog earlier.
I actually read the docs and saw the comment about the channel not being closed after calling Stop() but I figured it wasn't going to be an issue since src will edit anyway.
However now that I think about it, if src ever tried doing some background work like we do for sg (to check for an update whenever you run a command), then this could lead to an issue.
So I'll reinstate the former way I did it tomorrow, to avoid this. Thanks for taking a closer look @LawnGnome
Part 2 #44432
Closes #44432
Test plan
Manually tested that the banner shows up when there's an error from getting the current context for docker.