Skip to content

Commit f00f8c6

Browse files
committed
Merge branch 'main' into docs-faq-optional-coder-app
2 parents 3eec79a + c6366e5 commit f00f8c6

File tree

173 files changed

+4168
-2801
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+4168
-2801
lines changed

.github/actions/setup-node/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ runs:
1717
- name: Setup Node
1818
uses: buildjet/setup-node@v3
1919
with:
20-
node-version: 18.17.0
20+
node-version: 18.19.0
2121
# See https://github.com/actions/setup-node#caching-global-packages-data
2222
cache: "pnpm"
2323
cache-dependency-path: ${{ inputs.directory }}/pnpm-lock.yaml

.github/workflows/ci.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ jobs:
6060
- "examples/lima/**"
6161
db:
6262
- "**.sql"
63-
- "coderd/database/queries/**"
64-
- "coderd/database/migrations"
65-
- "coderd/database/sqlc.yaml"
66-
- "coderd/database/dump.sql"
63+
- "coderd/database/**"
6764
go:
6865
- "**.sql"
6966
- "**.go"
@@ -144,7 +141,7 @@ jobs:
144141
145142
# Check for any typos
146143
- name: Check for typos
147-
uses: crate-ci/typos@v1.16.25
144+
uses: crate-ci/typos@v1.16.26
148145
with:
149146
config: .github/workflows/typos.toml
150147

@@ -324,7 +321,6 @@ jobs:
324321
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
325322
needs:
326323
- changes
327-
- sqlc-vet # No point in testing the DB if the queries are invalid
328324
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
329325
# This timeout must be greater than the timeout set by `go test` in
330326
# `make test-postgres` to ensure we receive a trace of running
@@ -685,7 +681,7 @@ jobs:
685681
uses: ./.github/actions/setup-go
686682

687683
- name: Install nfpm
688-
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
684+
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.35.1
689685

690686
- name: Install zstd
691687
run: sudo apt-get install -y zstd

.github/workflows/dogfood.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515

1616
jobs:
1717
build_image:
18-
runs-on: buildjet-4vcpu-ubuntu-2204
18+
runs-on: ubuntu-latest
1919
steps:
2020
- name: Checkout
2121
uses: actions/checkout@v4
@@ -32,8 +32,8 @@ jobs:
3232
tag=${tag//\//--}
3333
echo "tag=${tag}" >> $GITHUB_OUTPUT
3434
35-
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@v3
35+
- name: Set up Depot CLI
36+
uses: depot/setup-action@v1
3737

3838
- name: Login to DockerHub
3939
if: github.ref == 'refs/heads/main'
@@ -43,14 +43,14 @@ jobs:
4343
password: ${{ secrets.DOCKERHUB_PASSWORD }}
4444

4545
- name: Build and push
46-
uses: docker/build-push-action@v5
46+
uses: depot/build-push-action@v1
4747
with:
48+
project: b4q6ltmpzh
49+
token: ${{ secrets.DEPOT_TOKEN }}
4850
context: "{{defaultContext}}:dogfood"
4951
pull: true
5052
push: ${{ github.ref == 'refs/heads/main' }}
5153
tags: "codercom/oss-dogfood:${{ steps.docker-tag-name.outputs.tag }},codercom/oss-dogfood:latest"
52-
cache-from: type=registry,ref=codercom/oss-dogfood:latest
53-
cache-to: type=inline
5454

5555
deploy_template:
5656
needs: build_image

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
- name: Install nfpm
104104
run: |
105105
set -euo pipefail
106-
wget -O /tmp/nfpm.deb https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.deb
106+
wget -O /tmp/nfpm.deb https://github.com/goreleaser/nfpm/releases/download/v2.35.1/nfpm_2.35.1_amd64.deb
107107
sudo dpkg -i /tmp/nfpm.deb
108108
rm /tmp/nfpm.deb
109109

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"contravariance",
2222
"cronstrue",
2323
"databasefake",
24-
"dbmem",
2524
"dbgen",
25+
"dbmem",
2626
"dbtype",
2727
"DERP",
2828
"derphttp",
@@ -118,13 +118,13 @@
118118
"stretchr",
119119
"STTY",
120120
"stuntest",
121-
"tanstack",
122121
"tailbroker",
123122
"tailcfg",
124123
"tailexchange",
125124
"tailnet",
126125
"tailnettest",
127126
"Tailscale",
127+
"tanstack",
128128
"tbody",
129129
"TCGETS",
130130
"tcpip",
@@ -141,6 +141,7 @@
141141
"tios",
142142
"tmpdir",
143143
"tokenconfig",
144+
"Topbar",
144145
"tparallel",
145146
"trialer",
146147
"trimprefix",

agent/agent.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
11881188
// startReportingConnectionStats runs the connection stats reporting goroutine.
11891189
func (a *agent) startReportingConnectionStats(ctx context.Context) {
11901190
reportStats := func(networkStats map[netlogtype.Connection]netlogtype.Counts) {
1191+
a.logger.Debug(ctx, "computing stats report")
11911192
stats := &agentsdk.Stats{
11921193
ConnectionCount: int64(len(networkStats)),
11931194
ConnectionsByProto: map[string]int64{},
@@ -1209,6 +1210,7 @@ func (a *agent) startReportingConnectionStats(ctx context.Context) {
12091210
stats.SessionCountReconnectingPTY = a.connCountReconnectingPTY.Load()
12101211

12111212
// Compute the median connection latency!
1213+
a.logger.Debug(ctx, "starting peer latency measurement for stats")
12121214
var wg sync.WaitGroup
12131215
var mu sync.Mutex
12141216
status := a.network.Status()
@@ -1257,13 +1259,17 @@ func (a *agent) startReportingConnectionStats(ctx context.Context) {
12571259

12581260
metricsCtx, cancelFunc := context.WithTimeout(ctx, 5*time.Second)
12591261
defer cancelFunc()
1262+
a.logger.Debug(ctx, "collecting agent metrics for stats")
12601263
stats.Metrics = a.collectMetrics(metricsCtx)
12611264

12621265
a.latestStat.Store(stats)
12631266

1267+
a.logger.Debug(ctx, "about to send stats")
12641268
select {
12651269
case a.connStatsChan <- stats:
1270+
a.logger.Debug(ctx, "successfully sent stats")
12661271
case <-a.closed:
1272+
a.logger.Debug(ctx, "didn't send stats because we are closed")
12671273
}
12681274
}
12691275

agent/agent_test.go

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ func TestAgent_Stats_Magic(t *testing.T) {
174174
require.NoError(t, err)
175175
err = session.Shell()
176176
require.NoError(t, err)
177-
var s *agentsdk.Stats
178177
require.Eventuallyf(t, func() bool {
179-
var ok bool
180-
s, ok = <-stats
178+
s, ok := <-stats
179+
t.Logf("got stats: ok=%t, ConnectionCount=%d, RxBytes=%d, TxBytes=%d, SessionCountVSCode=%d, ConnectionMedianLatencyMS=%f",
180+
ok, s.ConnectionCount, s.RxBytes, s.TxBytes, s.SessionCountVSCode, s.ConnectionMedianLatencyMS)
181181
return ok && s.ConnectionCount > 0 && s.RxBytes > 0 && s.TxBytes > 0 &&
182182
// Ensure that the connection didn't count as a "normal" SSH session.
183183
// This was a special one, so it should be labeled specially in the stats!
@@ -186,7 +186,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
186186
// If it isn't, it's set to -1.
187187
s.ConnectionMedianLatencyMS >= 0
188188
}, testutil.WaitLong, testutil.IntervalFast,
189-
"never saw stats: %+v", s,
189+
"never saw stats",
190190
)
191191
// The shell will automatically exit if there is no stdin!
192192
_ = stdin.Close()
@@ -240,14 +240,14 @@ func TestAgent_Stats_Magic(t *testing.T) {
240240
_ = tunneledConn.Close()
241241
})
242242

243-
var s *agentsdk.Stats
244243
require.Eventuallyf(t, func() bool {
245-
var ok bool
246-
s, ok = <-stats
244+
s, ok := <-stats
245+
t.Logf("got stats with conn open: ok=%t, ConnectionCount=%d, SessionCountJetBrains=%d",
246+
ok, s.ConnectionCount, s.SessionCountJetBrains)
247247
return ok && s.ConnectionCount > 0 &&
248248
s.SessionCountJetBrains == 1
249249
}, testutil.WaitLong, testutil.IntervalFast,
250-
"never saw stats with conn open: %+v", s,
250+
"never saw stats with conn open",
251251
)
252252

253253
// Kill the server and connection after checking for the echo.
@@ -256,12 +256,13 @@ func TestAgent_Stats_Magic(t *testing.T) {
256256
_ = tunneledConn.Close()
257257

258258
require.Eventuallyf(t, func() bool {
259-
var ok bool
260-
s, ok = <-stats
261-
return ok && s.ConnectionCount == 0 &&
259+
s, ok := <-stats
260+
t.Logf("got stats after disconnect %t, %d",
261+
ok, s.SessionCountJetBrains)
262+
return ok &&
262263
s.SessionCountJetBrains == 0
263264
}, testutil.WaitLong, testutil.IntervalFast,
264-
"never saw stats after conn closes: %+v", s,
265+
"never saw stats after conn closes",
265266
)
266267
})
267268
}
@@ -925,7 +926,7 @@ func TestAgent_EnvironmentVariableExpansion(t *testing.T) {
925926
func TestAgent_CoderEnvVars(t *testing.T) {
926927
t.Parallel()
927928

928-
for _, key := range []string{"CODER"} {
929+
for _, key := range []string{"CODER", "CODER_WORKSPACE_NAME", "CODER_WORKSPACE_AGENT_NAME"} {
929930
key := key
930931
t.Run(key, func(t *testing.T) {
931932
t.Parallel()
@@ -2014,6 +2015,12 @@ func setupAgent(t *testing.T, metadata agentsdk.Manifest, ptyTimeout time.Durati
20142015
if metadata.AgentID == uuid.Nil {
20152016
metadata.AgentID = uuid.New()
20162017
}
2018+
if metadata.AgentName == "" {
2019+
metadata.AgentName = "test-agent"
2020+
}
2021+
if metadata.WorkspaceName == "" {
2022+
metadata.WorkspaceName = "test-workspace"
2023+
}
20172024
coordinator := tailnet.NewCoordinator(logger)
20182025
t.Cleanup(func() {
20192026
_ = coordinator.Close()

agent/agentssh/agentssh.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,8 @@ func (s *Server) CreateCommand(ctx context.Context, script string, env []string)
659659
// Set environment variables reliable detection of being inside a
660660
// Coder workspace.
661661
cmd.Env = append(cmd.Env, "CODER=true")
662+
cmd.Env = append(cmd.Env, "CODER_WORKSPACE_NAME="+manifest.WorkspaceName)
663+
cmd.Env = append(cmd.Env, "CODER_WORKSPACE_AGENT_NAME="+manifest.AgentName)
662664
cmd.Env = append(cmd.Env, fmt.Sprintf("USER=%s", username))
663665
// Git on Windows resolves with UNIX-style paths.
664666
// If using backslashes, it's unable to find the executable.

agent/agentssh/jetbrainstrack.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package agentssh
22

33
import (
4+
"context"
45
"strings"
56
"sync"
67

@@ -26,6 +27,7 @@ type localForwardChannelData struct {
2627
type JetbrainsChannelWatcher struct {
2728
gossh.NewChannel
2829
jetbrainsCounter *atomic.Int64
30+
logger slog.Logger
2931
}
3032

3133
func NewJetbrainsChannelWatcher(ctx ssh.Context, logger slog.Logger, newChannel gossh.NewChannel, counter *atomic.Int64) gossh.NewChannel {
@@ -58,6 +60,7 @@ func NewJetbrainsChannelWatcher(ctx ssh.Context, logger slog.Logger, newChannel
5860
return &JetbrainsChannelWatcher{
5961
NewChannel: newChannel,
6062
jetbrainsCounter: counter,
63+
logger: logger.With(slog.F("destination_port", d.DestPort)),
6164
}
6265
}
6366

@@ -67,11 +70,15 @@ func (w *JetbrainsChannelWatcher) Accept() (gossh.Channel, <-chan *gossh.Request
6770
return c, r, err
6871
}
6972
w.jetbrainsCounter.Add(1)
73+
// nolint: gocritic // JetBrains is a proper noun and should be capitalized
74+
w.logger.Debug(context.Background(), "JetBrains watcher accepted channel")
7075

7176
return &ChannelOnClose{
7277
Channel: c,
7378
done: func() {
7479
w.jetbrainsCounter.Add(-1)
80+
// nolint: gocritic // JetBrains is a proper noun and should be capitalized
81+
w.logger.Debug(context.Background(), "JetBrains watcher channel closed")
7582
},
7683
}, r, err
7784
}

0 commit comments

Comments
 (0)