Skip to content

Commit b918c54

Browse files
authored
Merge branch 'coder:main' into main
2 parents 01386de + 8cf292f commit b918c54

File tree

412 files changed

+12124
-6901
lines changed

Some content is hidden

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

412 files changed

+12124
-6901
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141

4242
# Check for any typos!
4343
- name: Check for typos
44-
uses: crate-ci/typos@v1.13.9
44+
uses: crate-ci/typos@v1.13.14
4545
with:
4646
config: .github/workflows/typos.toml
4747
- name: Fix the typos
@@ -506,7 +506,7 @@ jobs:
506506
507507
- uses: actions/setup-node@v3
508508
with:
509-
node-version: "14"
509+
node-version: "16.16.0"
510510

511511
- name: Install node_modules
512512
run: ./scripts/yarn_install.sh
@@ -555,7 +555,7 @@ jobs:
555555

556556
- uses: actions/setup-node@v3
557557
with:
558-
node-version: "14"
558+
node-version: "16.16.0"
559559

560560
- name: Echo Go Cache Paths
561561
id: go-cache-paths
@@ -609,6 +609,10 @@ jobs:
609609
# only get 1 commit on shallow checkout.
610610
fetch-depth: 0
611611

612+
- uses: actions/setup-node@v3
613+
with:
614+
node-version: "16.16.0"
615+
612616
- name: Install dependencies
613617
run: cd site && yarn
614618

.github/workflows/contrib.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
steps:
3434
- name: cla
3535
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
36-
uses: contributor-assistant/github-action@v2.2.1
36+
uses: contributor-assistant/github-action@v2.3.0
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3939
# the below token should have repo scope and must be manually added by you in the repository's secret

.github/workflows/docker-base.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,38 @@ jobs:
5353
project: wl5hnrrkns
5454
context: base-build-context
5555
file: scripts/Dockerfile.base
56+
platforms: linux/amd64,linux/arm64,linux/arm/v7
5657
pull: true
5758
no-cache: true
5859
push: true
5960
tags: |
6061
ghcr.io/coder/coder-base:latest
62+
63+
- name: Verify that images are pushed properly
64+
run: |
65+
# retry 10 times with a 5 second delay as the images may not be
66+
# available immediately
67+
for i in {1..10}; do
68+
rc=0
69+
raw_manifests=$(docker buildx imagetools inspect --raw ghcr.io/coder/coder-base:latest) || rc=$?
70+
if [[ "$rc" -eq 0 ]]; then
71+
break
72+
fi
73+
if [[ "$i" -eq 10 ]]; then
74+
echo "Failed to pull manifests after 10 retries"
75+
exit 1
76+
fi
77+
echo "Failed to pull manifests, retrying in 5 seconds"
78+
sleep 5
79+
done
80+
81+
manifests=$(
82+
echo "$raw_manifests" | \
83+
jq -r '.manifests[].platform | .os + "/" + .architecture + (if .variant then "/" + .variant else "" end)'
84+
)
85+
86+
# Verify all 3 platforms are present.
87+
set -euxo pipefail
88+
echo "$manifests" | grep -q linux/amd64
89+
echo "$manifests" | grep -q linux/arm64
90+
echo "$manifests" | grep -q linux/arm/v7

.github/workflows/pr-auto-assign.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Filtering pull requests is much easier when we can reliably guarantee
2+
# that the "Assignee" field is populated.
3+
name: PR Auto Assign
4+
5+
on:
6+
pull_request_target:
7+
types: [opened]
8+
9+
permissions:
10+
pull-requests: write
11+
12+
jobs:
13+
assign-author:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: toshimaru/auto-author-assign@v1.6.2

.github/workflows/release.yaml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,42 @@ jobs:
188188
project: wl5hnrrkns
189189
context: base-build-context
190190
file: scripts/Dockerfile.base
191+
platforms: linux/amd64,linux/arm64,linux/arm/v7
191192
pull: true
192193
no-cache: true
193194
push: true
194195
tags: |
195196
${{ steps.image-base-tag.outputs.tag }}
196197
198+
- name: Verify that images are pushed properly
199+
run: |
200+
# retry 10 times with a 5 second delay as the images may not be
201+
# available immediately
202+
for i in {1..10}; do
203+
rc=0
204+
raw_manifests=$(docker buildx imagetools inspect --raw "${{ steps.image-base-tag.outputs.tag }}") || rc=$?
205+
if [[ "$rc" -eq 0 ]]; then
206+
break
207+
fi
208+
if [[ "$i" -eq 10 ]]; then
209+
echo "Failed to pull manifests after 10 retries"
210+
exit 1
211+
fi
212+
echo "Failed to pull manifests, retrying in 5 seconds"
213+
sleep 5
214+
done
215+
216+
manifests=$(
217+
echo "$raw_manifests" | \
218+
jq -r '.manifests[].platform | .os + "/" + .architecture + (if .variant then "/" + .variant else "" end)'
219+
)
220+
221+
# Verify all 3 platforms are present.
222+
set -euxo pipefail
223+
echo "$manifests" | grep -q linux/amd64
224+
echo "$manifests" | grep -q linux/arm64
225+
echo "$manifests" | grep -q linux/arm/v7
226+
197227
- name: Build Linux Docker images
198228
run: |
199229
set -euxo pipefail
@@ -275,7 +305,7 @@ jobs:
275305
276306
- name: Upload artifacts to actions (if dry-run)
277307
if: ${{ inputs.dry_run }}
278-
uses: actions/upload-artifact@v2
308+
uses: actions/upload-artifact@v3
279309
with:
280310
name: release-artifacts
281311
path: |

.github/workflows/security.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
echo "image=$(cat "$image_job")" >> $GITHUB_OUTPUT
117117
118118
- name: Run Trivy vulnerability scanner
119-
uses: aquasecurity/trivy-action@9ab158e8597f3b310480b9a69402b419bc03dbd5
119+
uses: aquasecurity/trivy-action@8bd2f9fbda2109502356ff8a6a89da55b1ead252
120120
with:
121121
image-ref: ${{ steps.build.outputs.image }}
122122
format: sarif
@@ -130,7 +130,7 @@ jobs:
130130
category: "Trivy"
131131

132132
- name: Upload Trivy scan results as an artifact
133-
uses: actions/upload-artifact@v2
133+
uses: actions/upload-artifact@v3
134134
with:
135135
name: trivy
136136
path: trivy-results.sarif

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"agentsdk",
55
"apps",
66
"ASKPASS",
7+
"authcheck",
78
"autostop",
89
"awsidentity",
910
"bodyclose",
@@ -113,6 +114,7 @@
113114
"stretchr",
114115
"STTY",
115116
"stuntest",
117+
"tanstack",
116118
"tailbroker",
117119
"tailcfg",
118120
"tailexchange",

Makefile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,15 @@ install: build/coder_$(VERSION)_$(GOOS)_$(GOARCH)$(GOOS_BIN_EXT)
368368
cp "$<" "$$output_file"
369369
.PHONY: install
370370

371-
fmt: fmt/prettier fmt/terraform fmt/shfmt
371+
fmt: fmt/prettier fmt/terraform fmt/shfmt fmt/go
372372
.PHONY: fmt
373373

374+
fmt/go:
375+
# VS Code users should check out
376+
# https://github.com/mvdan/gofumpt#visual-studio-code
377+
go run mvdan.cc/gofumpt@v0.4.0 -w -l .
378+
.PHONY: fmt/go
379+
374380
fmt/prettier:
375381
echo "--- prettier"
376382
cd site
@@ -418,7 +424,7 @@ gen: \
418424
provisionerd/proto/provisionerd.pb.go \
419425
site/src/api/typesGenerated.ts \
420426
docs/admin/prometheus.md \
421-
docs/cli/coder.md \
427+
docs/cli.md \
422428
docs/admin/audit-logs.md \
423429
coderd/apidoc/swagger.json \
424430
.prettierignore.include \
@@ -438,7 +444,7 @@ gen/mark-fresh:
438444
provisionerd/proto/provisionerd.pb.go \
439445
site/src/api/typesGenerated.ts \
440446
docs/admin/prometheus.md \
441-
docs/cli/coder.md \
447+
docs/cli.md \
442448
docs/admin/audit-logs.md \
443449
coderd/apidoc/swagger.json \
444450
.prettierignore.include \
@@ -494,10 +500,11 @@ docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/me
494500
cd site
495501
yarn run format:write:only ../docs/admin/prometheus.md
496502

497-
docs/cli/coder.md: scripts/clidocgen/main.go $(GO_SRC_FILES) docs/manifest.json
498-
BASE_PATH="." go run scripts/clidocgen/main.go
503+
docs/cli.md: scripts/clidocgen/main.go $(GO_SRC_FILES) docs/manifest.json
504+
rm -rf ./docs/cli/*.md
505+
BASE_PATH="." go run ./scripts/clidocgen
499506
cd site
500-
yarn run format:write:only ../docs/cli/*.md ../docs/manifest.json
507+
yarn run format:write:only ../docs/cli.md ../docs/cli/*.md ../docs/manifest.json
501508

502509
docs/admin/audit-logs.md: scripts/auditdocgen/main.go enterprise/audit/table.go
503510
go run scripts/auditdocgen/main.go

agent/agent.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (a *agent) runLoop(ctx context.Context) {
156156
go a.reportLifecycleLoop(ctx)
157157

158158
for retrier := retry.New(100*time.Millisecond, 10*time.Second); retrier.Wait(ctx); {
159-
a.logger.Info(ctx, "running loop")
159+
a.logger.Info(ctx, "connecting to coderd")
160160
err := a.run(ctx)
161161
// Cancel after the run is complete to clean up any leaked resources!
162162
if err == nil {
@@ -169,7 +169,7 @@ func (a *agent) runLoop(ctx context.Context) {
169169
return
170170
}
171171
if errors.Is(err, io.EOF) {
172-
a.logger.Info(ctx, "likely disconnected from coder", slog.Error(err))
172+
a.logger.Info(ctx, "disconnected from coderd")
173173
continue
174174
}
175175
a.logger.Warn(ctx, "run exited with error", slog.Error(err))
@@ -197,7 +197,7 @@ func (a *agent) reportLifecycleLoop(ctx context.Context) {
197197
break
198198
}
199199

200-
a.logger.Debug(ctx, "post lifecycle state", slog.F("state", state))
200+
a.logger.Debug(ctx, "reporting lifecycle state", slog.F("state", state))
201201

202202
err := a.client.PostLifecycle(ctx, agentsdk.PostLifecycleRequest{
203203
State: state,
@@ -242,7 +242,7 @@ func (a *agent) run(ctx context.Context) error {
242242
if err != nil {
243243
return xerrors.Errorf("fetch metadata: %w", err)
244244
}
245-
a.logger.Info(ctx, "fetched metadata")
245+
a.logger.Info(ctx, "fetched metadata", slog.F("metadata", metadata))
246246

247247
// Expand the directory and send it back to coderd so external
248248
// applications that rely on the directory can use it.
@@ -330,13 +330,10 @@ func (a *agent) run(ctx context.Context) error {
330330
go NewWorkspaceAppHealthReporter(
331331
a.logger, metadata.Apps, a.client.PostAppHealth)(appReporterCtx)
332332

333-
a.logger.Debug(ctx, "running tailnet with derpmap", slog.F("derpmap", metadata.DERPMap))
334-
335333
a.closeMutex.Lock()
336334
network := a.network
337335
a.closeMutex.Unlock()
338336
if network == nil {
339-
a.logger.Debug(ctx, "creating tailnet")
340337
network, err = a.createTailnet(ctx, metadata.DERPMap)
341338
if err != nil {
342339
return xerrors.Errorf("create tailnet: %w", err)
@@ -385,10 +382,9 @@ func (a *agent) run(ctx context.Context) error {
385382
network.SetDERPMap(metadata.DERPMap)
386383
}
387384

388-
a.logger.Debug(ctx, "running coordinator")
385+
a.logger.Debug(ctx, "running tailnet connection coordinator")
389386
err = a.runCoordinator(ctx, network)
390387
if err != nil {
391-
a.logger.Debug(ctx, "coordinator exited", slog.Error(err))
392388
return xerrors.Errorf("run coordinator: %w", err)
393389
}
394390
return nil
@@ -474,7 +470,9 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
474470
for {
475471
conn, err := reconnectingPTYListener.Accept()
476472
if err != nil {
477-
logger.Debug(ctx, "accept pty failed", slog.Error(err))
473+
if !a.isClosed() {
474+
logger.Debug(ctx, "accept pty failed", slog.Error(err))
475+
}
478476
break
479477
}
480478
wg.Add(1)
@@ -529,7 +527,9 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
529527
for {
530528
conn, err := speedtestListener.Accept()
531529
if err != nil {
532-
a.logger.Debug(ctx, "speedtest listener failed", slog.Error(err))
530+
if !a.isClosed() {
531+
a.logger.Debug(ctx, "speedtest listener failed", slog.Error(err))
532+
}
533533
break
534534
}
535535
wg.Add(1)
@@ -600,8 +600,10 @@ func (a *agent) runCoordinator(ctx context.Context, network *tailnet.Conn) error
600600
return err
601601
}
602602
defer coordinator.Close()
603-
a.logger.Info(ctx, "connected to coordination server")
604-
sendNodes, errChan := tailnet.ServeCoordinator(coordinator, network.UpdateNodes)
603+
a.logger.Info(ctx, "connected to coordination endpoint")
604+
sendNodes, errChan := tailnet.ServeCoordinator(coordinator, func(nodes []*tailnet.Node) error {
605+
return network.UpdateNodes(nodes, false)
606+
})
605607
network.SetNodeCallback(sendNodes)
606608
select {
607609
case <-ctx.Done():
@@ -644,7 +646,6 @@ func (a *agent) runStartupScript(ctx context.Context, script string) error {
644646
}
645647

646648
func (a *agent) init(ctx context.Context) {
647-
a.logger.Info(ctx, "generating host key")
648649
// Clients' should ignore the host key when connecting.
649650
// The agent needs to authenticate with coderd to SSH,
650651
// so SSH authentication doesn't improve security.
@@ -766,12 +767,12 @@ func (a *agent) init(ctx context.Context) {
766767

767768
func convertAgentStats(counts map[netlogtype.Connection]netlogtype.Counts) *agentsdk.Stats {
768769
stats := &agentsdk.Stats{
769-
ConnsByProto: map[string]int64{},
770-
NumConns: int64(len(counts)),
770+
ConnectionsByProto: map[string]int64{},
771+
ConnectionCount: int64(len(counts)),
771772
}
772773

773774
for conn, count := range counts {
774-
stats.ConnsByProto[conn.Proto.String()]++
775+
stats.ConnectionsByProto[conn.Proto.String()]++
775776
stats.RxPackets += int64(count.RxPackets)
776777
stats.RxBytes += int64(count.RxBytes)
777778
stats.TxPackets += int64(count.TxPackets)

0 commit comments

Comments
 (0)