Skip to content

Conversation

@victorges
Copy link
Member

What does this pull request do? Explain your changes. (required)
There was a slight race condition on shutdown as the watch routines tried to recreate the containers as we were removing them on shutdown.

Fixing this by keeping the lifecycle management in the watch container routine itself.

Specific updates (required)

  • Create a global ctx for the whole DockerManager which is closed on Stop
  • Create a sync.WaitGroup that gathers all background watchContainer routines
  • Destroy containers from within watchContainer when ctx is closed
  • Wait for watchContainer routines to stop before exiting

How did you test each of these updates (required)
The box ™️

Does this pull request close any open issues?
Fixes orphan containers after O shutdown.

Checklist:

There was a slight race condition on shutdown as the watch
routines tried to recreate the containers as we were removing
them on shutdown.

Fixing this by keeping the lifecycle management in the watch
container routine itself.
@github-actions github-actions bot added go Pull requests that update Go code AI Issues and PR related to the AI-video branch. labels Oct 15, 2025
@victorges victorges requested review from j0sh and mjh1 October 20, 2025 16:37
Copy link
Collaborator

@j0sh j0sh left a comment

Choose a reason for hiding this comment

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

Seems ok, it's a little confusing with the global context in addition to the per function contexts in Stop / Borrow but I don't really understand this bit enough to offer more constructive feedback, so LGTM

select {
case <-done:
return nil
case <-ctx.Done():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should m.ctx.Done() be checked as well or is that implicit in the wait group / done?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually the manager's ctx will always be done here, since we call m.stop() in the beginning

victorges and others added 2 commits October 23, 2025 21:40
Co-authored-by: Josh Allmann <[email protected]>
Co-authored-by: Josh Allmann <[email protected]>
@victorges victorges merged commit 1c02207 into master Oct 24, 2025
10 of 12 checks passed
@victorges victorges deleted the vg/fix/shutdown-race branch October 24, 2025 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Issues and PR related to the AI-video branch. go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants