Skip to content

add watchdog goroutine for docker#898

Merged
BolajiOlajide merged 8 commits into
mainfrom
bo/check-docker-responsiveness
Dec 9, 2022
Merged

add watchdog goroutine for docker#898
BolajiOlajide merged 8 commits into
mainfrom
bo/check-docker-responsiveness

Conversation

@BolajiOlajide

@BolajiOlajide BolajiOlajide commented Dec 7, 2022

Copy link
Copy Markdown
Contributor

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.

CleanShot 2022-12-07 at 19 26 03@2x

@LawnGnome LawnGnome left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generally LGTM. I'm surprised at how little code this actually was!

Comment thread internal/batches/watchdog/watchdog.go
Comment thread internal/batches/watchdog/watchdog.go Outdated
Comment thread internal/batches/ui/tui.go Outdated
Comment thread cmd/src/batch_common.go Outdated
@BolajiOlajide BolajiOlajide requested review from a team and LawnGnome December 8, 2022 21:12
Comment thread internal/batches/watchdog/watchdog.go Outdated
}

func (w *WatchDog) Start() {
for _ = range w.ticker.Chan() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

  1. We reinstate the previous, two channel behaviour, just with a return on the done case, or
  2. We decide we don't care about leaking a goroutine, because src is 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!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

@LawnGnome LawnGnome left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks again!

@BolajiOlajide BolajiOlajide enabled auto-merge (squash) December 9, 2022 21:40
@BolajiOlajide BolajiOlajide merged commit cbc5871 into main Dec 9, 2022
@BolajiOlajide BolajiOlajide deleted the bo/check-docker-responsiveness branch December 9, 2022 21:41
scjohns pushed a commit that referenced this pull request Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make it more clear when src-cli freezes because docker is unresponsive

3 participants