Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(agent/agentcontainers): add file watcher and dirty status#17573

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mafredri merged 23 commits intomainfrommafredri/feat-agent-agentcontainers-watch
Apr 29, 2025

Conversation

mafredri
Copy link
Member

server := &http.Server{
Handler: a.apiHandler(),
BaseContext: func(net.Listener) context.Context { return ctx },
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Review: This change allows allr.Contexts to inherit the graceful context from the agent, ensuring cancellation on agent shutdown.

return r
return r, func() error {
return containerAPI.Close()
}
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Review: We don't want to just rely on agent context, we will also explicitly clean up running services in the containerAPI.

@mafredrimafredri requested a review fromCopilotApril 28, 2025 11:21
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces file watcher functionality and a new “dirty” flag to track modifications in devcontainer configuration files. Key changes include:

  • Adding a “dirty” field to both the TypeScript and Go devcontainer types.
  • Implementing file watcher functionality using fsnotify and integrating it into the API to mark devcontainers as dirty on configuration changes.
  • Updating tests and API logic to clear the dirty flag appropriately after container recreation.

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
site/src/api/typesGenerated.tsAdded a new readonly “dirty” field to the WorkspaceAgentDevcontainer interface.
codersdk/workspaceagents.goAdded the Dirty boolean field for tracking runtime dirtiness.
agent/api.goModified apiHandler return signature and integrated cleanup; updated API logic for file watching.
agent/agentcontainers/watcher/*Added implementations and tests for file watchers (FSNotify and Noop).
agent/agentcontainers/api_test.go & api_internal_test.goUpdated tests to exercise file watcher behavior and dirty flag handling.
agent/agentcontainers/api.goIntegrated watcher logic within API methods to mark and clear the dirty flag.
agent/agent.goUpdated tailnet creation to use the new apiHandler cleanup functionality.
Files not reviewed (1)
  • go.mod: Language not supported
Comments suppressed due to low confidence (2)

agent/agentcontainers/api.go:476

  • [nitpick] Consider renaming 'configModifiedTimes' to 'configFileModifiedTimes' to improve clarity on its purpose.
api.configModifiedTimes[configPath] = modifiedAt

agent/agent.go:1484

  • Ensure that the cleanup function 'closeAPIHAndler' is invoked in all execution paths to avoid resource leaks, even if an error occurs later on.
apiHandler, closeAPIHAndler := a.apiHandler()

@mafredrimafredri marked this pull request as ready for reviewApril 28, 2025 11:29
@mafredrimafredriforce-pushed themafredri/feat-agent-agentcontainers-watch branch fromcfbd699 to51fb44eCompareApril 28, 2025 11:38
@mafredrimafredriforce-pushed themafredri/feat-agent-agentcontainers-watch branch from51fb44e tobfeb1daCompareApril 28, 2025 11:39
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this package could be moved outside ofagentcontainers for later re-use, but that doesn't have to be done in this PR.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It's a valid suggestion, but I'd like to defer until the need arises to keep devcontainer related stuff contained (heh).

johnstcn reacted with thumbs up emojijohnstcn reacted with laugh emoji
@mafredrimafredriforce-pushed themafredri/feat-agent-agentcontainers-watch branch from9f483ed to9cf5415CompareApril 28, 2025 12:38
@mafredrimafredriforce-pushed themafredri/feat-agent-agentcontainers-watch branch from0b16448 toeaf5922CompareApril 28, 2025 13:05
@mafredrimafredri requested a review fromCopilotApril 28, 2025 13:40
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a file watcher and introduces a dirty flag to track when devcontainer configuration files change. Key changes include adding a "dirty" property to devcontainer types, integrating a file system watcher into the API logic, and supplementing the feature with comprehensive tests.

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
site/src/api/typesGenerated.tsAdded a "dirty" flag to WorkspaceAgentDevcontainer interface.
codersdk/workspaceagents.goAdded a "Dirty" field to the Go struct representing the devcontainer.
agent/api.goModified apiHandler signature and integrated file watcher functionality.
agent/agentcontainers/watcher/*Added and tested file watcher implementations (fsnotify and noop).
agent/agentcontainers/api*.goUpdated API logic to track dirty state and integrate file watcher events.
agent/agent.goUpdated tailnet creation logic to obtain and close the API handler.
Files not reviewed (1)
  • go.mod: Language not supported

@mafredrimafredri requested a review fromjohnstcnApril 28, 2025 13:54
lockCh: make(chan struct{}, 1),
devcontainerNames: make(map[string]struct{}),
knownDevcontainers: []codersdk.WorkspaceAgentDevcontainer{},
configFileModifiedTimes: make(map[string]time.Time),
Copy link
Member

Choose a reason for hiding this comment

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

This is fine for now, but if we ever decide to expose this in the API we may want to refactor this to amap[string]codersdk.NullTime

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Not sure we need to store a null time in the map, that can already be represented by missing map entry or zero time. But if we expose it incodersdk types then we can totally use that type there 👍🏻

@mafredrimafredri merged commit268a50c intomainApr 29, 2025
30 of 32 checks passed
@mafredrimafredri deleted the mafredri/feat-agent-agentcontainers-watch branchApril 29, 2025 08:54
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 29, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

Copilot code reviewCopilotCopilot left review comments

@johnstcnjohnstcnjohnstcn approved these changes

@DanielleMaywoodDanielleMaywoodAwaiting requested review from DanielleMaywood

Assignees

@mafredrimafredri

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

agent: keep track of devcontainer 'dirty' status agent: implement a function to watch a set of files for changes usinginotify or similar on Linux
2 participants
@mafredri@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp