mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(agent): Add SSH max timeout option for coder agent (#6596)
* feat(agent): Add SSH max timeout option for coder agent * Fix lint and update test golden snapshot
This commit is contained in:
+7
-3
@@ -78,6 +78,7 @@ type Options struct {
|
||||
EnvironmentVariables map[string]string
|
||||
Logger slog.Logger
|
||||
AgentPorts map[int]string
|
||||
SSHMaxTimeout time.Duration
|
||||
}
|
||||
|
||||
type Client interface {
|
||||
@@ -126,6 +127,7 @@ func New(options Options) io.Closer {
|
||||
lifecycleReported: make(chan codersdk.WorkspaceAgentLifecycle, 1),
|
||||
ignorePorts: options.AgentPorts,
|
||||
connStatsChan: make(chan *agentsdk.Stats, 1),
|
||||
sshMaxTimeout: options.SSHMaxTimeout,
|
||||
}
|
||||
a.init(ctx)
|
||||
return a
|
||||
@@ -153,9 +155,10 @@ type agent struct {
|
||||
|
||||
envVars map[string]string
|
||||
// metadata is atomic because values can change after reconnection.
|
||||
metadata atomic.Value
|
||||
sessionToken atomic.Pointer[string]
|
||||
sshServer *ssh.Server
|
||||
metadata atomic.Value
|
||||
sessionToken atomic.Pointer[string]
|
||||
sshServer *ssh.Server
|
||||
sshMaxTimeout time.Duration
|
||||
|
||||
lifecycleUpdate chan struct{}
|
||||
lifecycleReported chan codersdk.WorkspaceAgentLifecycle
|
||||
@@ -780,6 +783,7 @@ func (a *agent) init(ctx context.Context) {
|
||||
_ = session.Exit(1)
|
||||
},
|
||||
},
|
||||
MaxTimeout: a.sshMaxTimeout,
|
||||
}
|
||||
|
||||
go a.runLoop(ctx)
|
||||
|
||||
Reference in New Issue
Block a user