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: addcoder exp sync commands to allow script orchestration#20579

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

Draft
SasSwart wants to merge18 commits intomain
base:main
Choose a base branch
Loading
fromjjs/internal-1095-cli
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
18 commits
Select commitHold shift + click to select a range
e3dfe45
LLM generated implementation of unit status change communication
SasSwartOct 27, 2025
851c4f9
add a socket to the agent for local IPC
SasSwartOct 28, 2025
34c1370
fix agent socket tests
SasSwartOct 28, 2025
9ca30e2
add a prototype cli command that uses the agent socket
SasSwartOct 28, 2025
4616c82
switch agent socket to drpc. factor components and add tests
SasSwartOct 30, 2025
55c5b70
Rename unit.DependencyTracker to unit.Manager
SasSwartOct 30, 2025
8644712
make the agent socket path configurable
SasSwartOct 30, 2025
216a5ac
document initSocketServer and tweak its log levels
SasSwartOct 30, 2025
c322b92
remove agent socket auth for now
SasSwartOct 30, 2025
8c0bfcb
Improve agentsocket rpc naming and documentation
SasSwartOct 30, 2025
e6873c8
rename dependency_tracker.go to manager.go
SasSwartOct 30, 2025
f550028
Move unit statuses to the appropriate package
SasSwartOct 30, 2025
820d53b
streamline agentsocket server initialization
SasSwartOct 30, 2025
89b060e
hide functions that do not need to be public
SasSwartOct 30, 2025
0d3d493
fix an incomplete refactor
SasSwartOct 30, 2025
217ddf4
fix an incomplete refactor
SasSwartOct 30, 2025
10d4e42
remove defunct files
SasSwartOct 30, 2025
9764926
remove defunct test file
SasSwartOct 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletionsMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -642,6 +642,7 @@ AIBRIDGED_MOCKS := \
GEN_FILES := \
tailnet/proto/tailnet.pb.go \
agent/proto/agent.pb.go \
agent/agentsocket/proto/agentsocket.pb.go \
provisionersdk/proto/provisioner.pb.go \
provisionerd/proto/provisionerd.pb.go \
vpn/vpn.pb.go \
Expand DownExpand Up@@ -800,6 +801,14 @@ agent/proto/agent.pb.go: agent/proto/agent.proto
--go-drpc_opt=paths=source_relative \
./agent/proto/agent.proto

agent/agentsocket/proto/agentsocket.pb.go: agent/agentsocket/proto/agentsocket.proto
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./agent/agentsocket/proto/agentsocket.proto

provisionersdk/proto/provisioner.pb.go: provisionersdk/proto/provisioner.proto
protoc \
--go_out=. \
Expand Down
39 changes: 39 additions & 0 deletionsagent/agent.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,6 +40,7 @@ import (
"github.com/coder/coder/v2/agent/agentcontainers"
"github.com/coder/coder/v2/agent/agentexec"
"github.com/coder/coder/v2/agent/agentscripts"
"github.com/coder/coder/v2/agent/agentsocket"
"github.com/coder/coder/v2/agent/agentssh"
"github.com/coder/coder/v2/agent/proto"
"github.com/coder/coder/v2/agent/proto/resourcesmonitor"
Expand DownExpand Up@@ -91,6 +92,7 @@ type Options struct {
Devcontainers bool
DevcontainerAPIOptions []agentcontainers.Option // Enable Devcontainers for these to be effective.
Clock quartz.Clock
SocketPath string // Path for the agent socket server
}

type Client interface {
Expand DownExpand Up@@ -190,6 +192,7 @@ func New(options Options) Agent {

devcontainers: options.Devcontainers,
containerAPIOptions: options.DevcontainerAPIOptions,
socketPath: options.SocketPath,
}
// Initially, we have a closed channel, reflecting the fact that we are not initially connected.
// Each time we connect we replace the channel (while holding the closeMutex) with a new one
Expand DownExpand Up@@ -271,6 +274,9 @@ type agent struct {
devcontainers bool
containerAPIOptions []agentcontainers.Option
containerAPI *agentcontainers.API

socketPath string
socketServer *agentsocket.Server
}

func (a *agent) TailnetConn() *tailnet.Conn {
Expand DownExpand Up@@ -350,9 +356,35 @@ func (a *agent) init() {
s.ExperimentalContainers = a.devcontainers
},
)

a.initSocketServer()

go a.runLoop()
}

// initSocketServer initializes server that allows direct communication with a workspace agent using IPC.
func (a *agent) initSocketServer() {
if a.socketPath == "" {
a.logger.Info(a.hardCtx, "socket server disabled (no path configured)")
return
}

server, err := agentsocket.NewServer(a.socketPath, a.logger.Named("socket"))
if err != nil {
a.logger.Warn(a.hardCtx, "failed to create socket server", slog.Error(err))
return
}

err = server.Start()
if err != nil {
a.logger.Warn(a.hardCtx, "failed to start socket server", slog.Error(err))
return
}

a.socketServer = server
a.logger.Debug(a.hardCtx, "socket server started", slog.F("path", a.socketPath))
}

// runLoop attempts to start the agent in a retry loop.
// Coder may be offline temporarily, a connection issue
// may be happening, but regardless after the intermittent
Expand DownExpand Up@@ -1920,6 +1952,13 @@ func (a *agent) Close() error {
lifecycleState = codersdk.WorkspaceAgentLifecycleShutdownError
}
}

if a.socketServer != nil {
if err := a.socketServer.Stop(); err != nil {
a.logger.Error(a.hardCtx, "socket server close", slog.Error(err))
}
}

a.setLifecycle(lifecycleState)

err = a.scriptRunner.Close()
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp