Skip to content

feat(agent/agentcontainers): update containers periodically #17972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 22, 2025
Merged

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented May 21, 2025

This change introduces a significant refactor to the agentcontainers API
and enables periodic updates of Docker containers rather than on-demand.
Consequently this change also allows us to move away from using a
locking channel and replace it with a mutex, which simplifies usage.

Additionally a previous oversight was fixed, and testing added, to clear
devcontainer running/dirty status when the container has been removed.

Updates #16424
Updates coder/internal#621

@mafredri mafredri force-pushed the mafredri/wip branch 4 times, most recently from 84e7fb1 to 25ead7b Compare May 21, 2025 15:51
@mafredri mafredri requested a review from Copilot May 21, 2025 15:52
Copilot

This comment was marked as resolved.

This change introduces a significant refactor to the agentcontainers API
and enabled periodic updates of Docker containers rather than on-demand.
Consequently this change also allows us to move away from using a
locking channel and replace it with a mutex, which simplifies usage.

Additionally a previous oversight was fixed, and testing added, to clear
devcontainer running/dirty status when the container has been removed.

Updates #16424
Updates coder/internal#621
@mafredri mafredri marked this pull request as ready for review May 21, 2025 16:02
Comment on lines 264 to 266
defer func() { sema <- struct{}{} }()

return api.updateContainers(api.ctx)
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense instead to just return early from doUpdate() if we're not able to read from sema? Queueing multiple updates seems like it could cause increased memory usage over time, and I'm not sure what value we get from running it right again after one instance has just completed.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we did that, we can't wait for it to complete in the refreshContainers function. I'll see if there's any point in keeping a refresh method around after I refactor the recreate endpoint.

@mafredri mafredri requested a review from johnstcn May 22, 2025 10:07
Copy link
Contributor

@DanielleMaywood DanielleMaywood left a comment

Choose a reason for hiding this comment

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

looks good to me 😄

@mafredri mafredri merged commit d6c14f3 into main May 22, 2025
34 checks passed
@mafredri mafredri deleted the mafredri/wip branch May 22, 2025 16:44
@github-actions github-actions bot locked and limited conversation to collaborators May 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants