Skip to content

Commit 41ce694

Browse files
committed
Merge remote-tracking branch 'origin/main' into agent-metadata
2 parents c30f1c6 + 7076dee commit 41ce694

File tree

25 files changed

+1281
-379
lines changed

25 files changed

+1281
-379
lines changed

agent/agent.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ type Options struct {
7979
EnvironmentVariables map[string]string
8080
Logger slog.Logger
8181
AgentPorts map[int]string
82+
SSHMaxTimeout time.Duration
8283
}
8384

8485
type Client interface {
@@ -128,6 +129,7 @@ func New(options Options) io.Closer {
128129
lifecycleReported: make(chan codersdk.WorkspaceAgentLifecycle, 1),
129130
ignorePorts: options.AgentPorts,
130131
connStatsChan: make(chan *agentsdk.Stats, 1),
132+
sshMaxTimeout: options.SSHMaxTimeout,
131133
}
132134
a.init(ctx)
133135
return a
@@ -155,9 +157,10 @@ type agent struct {
155157

156158
envVars map[string]string
157159
// manifest is atomic because values can change after reconnection.
158-
manifest atomic.Pointer[agentsdk.Manifest]
159-
sessionToken atomic.Pointer[string]
160-
sshServer *ssh.Server
160+
manifest atomic.Pointer[agentsdk.Manifest]
161+
sessionToken atomic.Pointer[string]
162+
sshServer *ssh.Server
163+
sshMaxTimeout time.Duration
161164

162165
lifecycleUpdate chan struct{}
163166
lifecycleReported chan codersdk.WorkspaceAgentLifecycle
@@ -809,6 +812,7 @@ func (a *agent) init(ctx context.Context) {
809812
_ = session.Exit(1)
810813
},
811814
},
815+
MaxTimeout: a.sshMaxTimeout,
812816
}
813817

814818
go a.runLoop(ctx)

cli/agent.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ import (
3131

3232
func workspaceAgent() *cobra.Command {
3333
var (
34-
auth string
35-
logDir string
36-
pprofAddress string
37-
noReap bool
34+
auth string
35+
logDir string
36+
pprofAddress string
37+
noReap bool
38+
sshMaxTimeout time.Duration
3839
)
3940
cmd := &cobra.Command{
4041
Use: "agent",
@@ -208,7 +209,8 @@ func workspaceAgent() *cobra.Command {
208209
EnvironmentVariables: map[string]string{
209210
"GIT_ASKPASS": executablePath,
210211
},
211-
AgentPorts: agentPorts,
212+
AgentPorts: agentPorts,
213+
SSHMaxTimeout: sshMaxTimeout,
212214
})
213215
<-ctx.Done()
214216
return closer.Close()
@@ -219,6 +221,7 @@ func workspaceAgent() *cobra.Command {
219221
cliflag.StringVarP(cmd.Flags(), &logDir, "log-dir", "", "CODER_AGENT_LOG_DIR", os.TempDir(), "Specify the location for the agent log files")
220222
cliflag.StringVarP(cmd.Flags(), &pprofAddress, "pprof-address", "", "CODER_AGENT_PPROF_ADDRESS", "127.0.0.1:6060", "The address to serve pprof.")
221223
cliflag.BoolVarP(cmd.Flags(), &noReap, "no-reap", "", "", false, "Do not start a process reaper.")
224+
cliflag.DurationVarP(cmd.Flags(), &sshMaxTimeout, "ssh-max-timeout", "", "CODER_AGENT_SSH_MAX_TIMEOUT", time.Duration(0), "Specify the max timeout for a SSH connection")
222225
return cmd
223226
}
224227

cli/testdata/coder_agent_--help.golden

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ Usage:
22
coder agent [flags]
33

44
Flags:
5-
--auth string Specify the authentication type to use for the agent.
6-
Consumes $CODER_AGENT_AUTH (default "token")
7-
-h, --help help for agent
8-
--log-dir string Specify the location for the agent log files.
9-
Consumes $CODER_AGENT_LOG_DIR (default "/tmp")
10-
--no-reap Do not start a process reaper.
11-
--pprof-address string The address to serve pprof.
12-
Consumes $CODER_AGENT_PPROF_ADDRESS (default "127.0.0.1:6060")
5+
--auth string Specify the authentication type to use for the agent.
6+
Consumes $CODER_AGENT_AUTH (default "token")
7+
-h, --help help for agent
8+
--log-dir string Specify the location for the agent log files.
9+
Consumes $CODER_AGENT_LOG_DIR (default "/tmp")
10+
--no-reap Do not start a process reaper.
11+
--pprof-address string The address to serve pprof.
12+
Consumes $CODER_AGENT_PPROF_ADDRESS (default "127.0.0.1:6060")
13+
--ssh-max-timeout duration Specify the max timeout for a SSH connection.
14+
Consumes $CODER_AGENT_SSH_MAX_TIMEOUT
1315

1416
Global Flags:
1517
--global-config coder Path to the global coder config directory.

docs/admin/configure.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ subdomain that resolves to Coder (e.g. `*.coder.example.com`).
4646

4747
The Coder server can directly use TLS certificates with `CODER_TLS_ENABLE` and accompanying configuration flags. However, Coder can also run behind a reverse-proxy to terminate TLS certificates from LetsEncrypt, for example.
4848

49-
- Apache: [Run Coder with Apache and LetsEncrypt](https://github.com/coder/coder/tree/main/examples/web-server/apache)
50-
- Caddy: [Run Coder with Caddy and LetsEncrypt](https://github.com/coder/coder/tree/main/examples/web-server/caddy)
51-
- NGINX: [Run Coder with Nginx and LetsEncrypt](https://github.com/coder/coder/tree/main/examples/web-server/nginx)
49+
- [Apache](https://github.com/coder/coder/tree/main/examples/web-server/apache)
50+
- [Caddy](https://github.com/coder/coder/tree/main/examples/web-server/caddy)
51+
- [NGINX](https://github.com/coder/coder/tree/main/examples/web-server/nginx)
5252

5353
## PostgreSQL Database
5454

examples/templates/aws-ecs-container/main.tf

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "~> 0.6.12"
5+
version = "~> 0.6.17"
66
}
77
aws = {
88
source = "hashicorp/aws"
@@ -11,16 +11,28 @@ terraform {
1111
}
1212
}
1313

14+
provider "coder" {
15+
feature_use_managed_variables = true
16+
}
17+
1418
variable "ecs-cluster" {
1519
description = "Input the ECS cluster ARN to host the workspace"
16-
default = ""
1720
}
18-
variable "cpu" {
19-
default = "1024"
21+
22+
data "coder_parameter" "cpu" {
23+
name = "cpu"
24+
description = "The number of CPU units to reserve for the container"
25+
type = "number"
26+
default = "1024"
27+
mutable = true
2028
}
2129

22-
variable "memory" {
23-
default = "2048"
30+
data "coder_parameter" "memory" {
31+
name = "memory"
32+
description = "The amount of memory (in MiB) to allow the container to use"
33+
type = "number"
34+
default = "2048"
35+
mutable = true
2436
}
2537

2638
# configure AWS provider with creds present on Coder server host
@@ -34,14 +46,14 @@ resource "aws_ecs_task_definition" "workspace" {
3446
family = "coder"
3547

3648
requires_compatibilities = ["EC2"]
37-
cpu = var.cpu
38-
memory = var.memory
49+
cpu = data.coder_parameter.cpu.value
50+
memory = data.coder_parameter.memory.value
3951
container_definitions = jsonencode([
4052
{
4153
name = "coder-workspace-${data.coder_workspace.me.id}"
4254
image = "codercom/enterprise-base:ubuntu"
43-
cpu = 1024
44-
memory = 2048
55+
cpu = tonumber(data.coder_parameter.cpu.value)
56+
memory = tonumber(data.coder_parameter.memory.value)
4557
essential = true
4658
user = "coder"
4759
command = ["sh", "-c", coder_agent.coder.init_script]
@@ -92,11 +104,10 @@ resource "aws_ecs_service" "workspace" {
92104
data "coder_workspace" "me" {}
93105

94106
resource "coder_agent" "coder" {
95-
arch = "amd64"
96-
auth = "token"
97-
os = "linux"
98-
dir = "/home/coder"
99-
107+
arch = "amd64"
108+
auth = "token"
109+
os = "linux"
110+
dir = "/home/coder"
100111
login_before_ready = false
101112
startup_script_timeout = 180
102113
startup_script = <<-EOT

0 commit comments

Comments
 (0)