Skip to content

Commit ad237ad

Browse files
committed
Merge branch 'main' into jon/glue
2 parents 358aaa8 + 095c979 commit ad237ad

Some content is hidden

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

51 files changed

+3095
-350
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ jobs:
9090
- "coderd/**"
9191
- "enterprise/**"
9292
- "examples/*"
93+
- "helm/**"
9394
- "provisioner/**"
9495
- "provisionerd/**"
9596
- "provisionersdk/**"
@@ -970,7 +971,7 @@ jobs:
970971
uses: google-github-actions/setup-gcloud@f0990588f1e5b5af6827153b93673613abdc6ec7 # v2.1.1
971972

972973
- name: Set up Flux CLI
973-
uses: fluxcd/flux2/action@9b3958825a314eb79495c6993ef397ddbf87f32f # v2.2.1
974+
uses: fluxcd/flux2/action@5350425cdcd5fa015337e09fa502153c0275bd4b # v2.4.0
974975
with:
975976
# Keep this and the github action up to date with the version of flux installed in dogfood cluster
976977
version: "2.2.1"

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ jobs:
4747

4848
# Upload the results to GitHub's code scanning dashboard.
4949
- name: "Upload to code-scanning"
50-
uses: github/codeql-action/upload-sarif@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
50+
uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
5151
with:
5252
sarif_file: results.sarif

.github/workflows/security.yaml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
uses: ./.github/actions/setup-go
3838

3939
- name: Initialize CodeQL
40-
uses: github/codeql-action/init@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
40+
uses: github/codeql-action/init@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
4141
with:
4242
languages: go, javascript
4343

@@ -47,7 +47,7 @@ jobs:
4747
rm Makefile
4848
4949
- name: Perform CodeQL Analysis
50-
uses: github/codeql-action/analyze@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
50+
uses: github/codeql-action/analyze@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
5151

5252
- name: Send Slack notification on failure
5353
if: ${{ failure() }}
@@ -96,7 +96,7 @@ jobs:
9696
# version in the comments will differ. This is also defined in
9797
# ci.yaml.
9898
set -x
99-
cd dogfood
99+
cd dogfood/contents
100100
DOCKER_BUILDKIT=1 docker build . --target proto -t protoc
101101
protoc_path=/usr/local/bin/protoc
102102
docker run --rm --entrypoint cat protoc /tmp/bin/protoc > $protoc_path
@@ -124,15 +124,15 @@ jobs:
124124
echo "image=$(cat "$image_job")" >> $GITHUB_OUTPUT
125125
126126
- name: Run Trivy vulnerability scanner
127-
uses: aquasecurity/trivy-action@5681af892cd0f4997658e2bacc62bd0a894cf564
127+
uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2
128128
with:
129129
image-ref: ${{ steps.build.outputs.image }}
130130
format: sarif
131131
output: trivy-results.sarif
132132
severity: "CRITICAL,HIGH"
133133

134134
- name: Upload Trivy scan results to GitHub Security tab
135-
uses: github/codeql-action/upload-sarif@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
135+
uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
136136
with:
137137
sarif_file: trivy-results.sarif
138138
category: "Trivy"
@@ -144,16 +144,6 @@ jobs:
144144
path: trivy-results.sarif
145145
retention-days: 7
146146

147-
# Prisma cloud scan runs last because it fails the entire job if it
148-
# detects vulnerabilities. :|
149-
- name: Run Prisma Cloud image scan
150-
uses: PaloAltoNetworks/prisma-cloud-scan@1f38c94d789ff9b01a4e80070b442294ebd3e362 # v1.4.0
151-
with:
152-
pcc_console_url: ${{ secrets.PRISMA_CLOUD_URL }}
153-
pcc_user: ${{ secrets.PRISMA_CLOUD_ACCESS_KEY }}
154-
pcc_pass: ${{ secrets.PRISMA_CLOUD_SECRET_KEY }}
155-
image_name: ${{ steps.build.outputs.image }}
156-
157147
- name: Send Slack notification on failure
158148
if: ${{ failure() }}
159149
run: |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DELETE FROM notification_templates WHERE id = 'f40fae84-55a2-42cd-99fa-b41c1ca64894';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
INSERT INTO notification_templates
2+
(id, name, title_template, body_template, "group", actions)
3+
VALUES (
4+
'f40fae84-55a2-42cd-99fa-b41c1ca64894',
5+
'Template Deprecated',
6+
E'Template ''{{.Labels.template}}'' has been deprecated',
7+
E'Hello {{.UserName}},\n\n'||
8+
E'The template **{{.Labels.template}}** has been deprecated with the following message:\n\n' ||
9+
E'**{{.Labels.message}}**\n\n' ||
10+
E'New workspaces may not be created from this template. Existing workspaces will continue to function normally.',
11+
'Template Events',
12+
'[
13+
{
14+
"label": "See affected workspaces",
15+
"url": "{{base_url}}/workspaces?filter=owner%3Ame+template%3A{{.Labels.template}}"
16+
},
17+
{
18+
"label": "View template",
19+
"url": "{{base_url}}/templates/{{.Labels.organization}}/{{.Labels.template}}"
20+
}
21+
]'::jsonb
22+
);

coderd/notifications/events.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ var (
3030

3131
// Template-related events.
3232
var (
33-
TemplateTemplateDeleted = uuid.MustParse("29a09665-2a4c-403f-9648-54301670e7be")
33+
TemplateTemplateDeleted = uuid.MustParse("29a09665-2a4c-403f-9648-54301670e7be")
34+
TemplateTemplateDeprecated = uuid.MustParse("f40fae84-55a2-42cd-99fa-b41c1ca64894")
3435

3536
TemplateWorkspaceBuildsFailedReport = uuid.MustParse("34a20db2-e9cc-4a93-b0e4-8569699d7a00")
3637
)

coderd/notifications/notifications_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,20 @@ func TestNotificationTemplates_Golden(t *testing.T) {
10211021
appName: "Custom Application Name",
10221022
logoURL: "https://custom.application/logo.png",
10231023
},
1024+
{
1025+
name: "TemplateTemplateDeprecated",
1026+
id: notifications.TemplateTemplateDeprecated,
1027+
payload: types.MessagePayload{
1028+
UserName: "Bobby",
1029+
UserEmail: "bobby@coder.com",
1030+
UserUsername: "bobby",
1031+
Labels: map[string]string{
1032+
"template": "alpha",
1033+
"message": "This template has been replaced by beta",
1034+
"organization": "coder",
1035+
},
1036+
},
1037+
},
10241038
}
10251039

10261040
// We must have a test case for every notification_template. This is enforced below:
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
From: system@coder.com
2+
To: bobby@coder.com
3+
Subject: Template 'alpha' has been deprecated
4+
Message-Id: 02ee4935-73be-4fa1-a290-ff9999026b13@blush-whale-48
5+
Date: Fri, 11 Oct 2024 09:03:06 +0000
6+
Content-Type: multipart/alternative; boundary=bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4
7+
MIME-Version: 1.0
8+
9+
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4
10+
Content-Transfer-Encoding: quoted-printable
11+
Content-Type: text/plain; charset=UTF-8
12+
13+
Hello Bobby,
14+
15+
The template alpha has been deprecated with the following message:
16+
17+
This template has been replaced by beta
18+
19+
New workspaces may not be created from this template. Existing workspaces w=
20+
ill continue to function normally.
21+
22+
23+
See affected workspaces: http://test.com/workspaces?filter=3Downer%3Ame+tem=
24+
plate%3Aalpha
25+
26+
View template: http://test.com/templates/coder/alpha
27+
28+
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4
29+
Content-Transfer-Encoding: quoted-printable
30+
Content-Type: text/html; charset=UTF-8
31+
32+
<!doctype html>
33+
<html lang=3D"en">
34+
<head>
35+
<meta charset=3D"UTF-8" />
36+
<meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-scale=
37+
=3D1.0" />
38+
<title>Template 'alpha' has been deprecated</title>
39+
</head>
40+
<body style=3D"margin: 0; padding: 0; font-family: -apple-system, system-=
41+
ui, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarel=
42+
l', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; color: #020617=
43+
; background: #f8fafc;">
44+
<div style=3D"max-width: 600px; margin: 20px auto; padding: 60px; borde=
45+
r: 1px solid #e2e8f0; border-radius: 8px; background-color: #fff; text-alig=
46+
n: left; font-size: 14px; line-height: 1.5;">
47+
<div style=3D"text-align: center;">
48+
<img src=3D"https://coder.com/coder-logo-horizontal.png" alt=3D"Cod=
49+
er Logo" style=3D"height: 40px;" />
50+
</div>
51+
<h1 style=3D"text-align: center; font-size: 24px; font-weight: 400; m=
52+
argin: 8px 0 32px; line-height: 1.5;">
53+
Template 'alpha' has been deprecated
54+
</h1>
55+
<div style=3D"line-height: 1.5;">
56+
<p>Hello Bobby,</p>
57+
58+
<p>The template <strong>alpha</strong> has been deprecated with the followi=
59+
ng message:</p>
60+
61+
<p><strong>This template has been replaced by beta</strong></p>
62+
63+
<p>New workspaces may not be created from this template. Existing workspace=
64+
s will continue to function normally.</p>
65+
</div>
66+
<div style=3D"text-align: center; margin-top: 32px;">
67+
=20
68+
<a href=3D"http://test.com/workspaces?filter=3Downer%3Ame+template%=
69+
3Aalpha" style=3D"display: inline-block; padding: 13px 24px; background-col=
70+
or: #020617; color: #f8fafc; text-decoration: none; border-radius: 8px; mar=
71+
gin: 0 4px;">
72+
See affected workspaces
73+
</a>
74+
=20
75+
<a href=3D"http://test.com/templates/coder/alpha" style=3D"display:=
76+
inline-block; padding: 13px 24px; background-color: #020617; color: #f8faf=
77+
c; text-decoration: none; border-radius: 8px; margin: 0 4px;">
78+
View template
79+
</a>
80+
=20
81+
</div>
82+
<div style=3D"border-top: 1px solid #e2e8f0; color: #475569; font-siz=
83+
e: 12px; margin-top: 64px; padding-top: 24px; line-height: 1.6;">
84+
<p>&copy;&nbsp;2024&nbsp;Coder. All rights reserved&nbsp;-&nbsp;<a =
85+
href=3D"http://test.com" style=3D"color: #2563eb; text-decoration: none;">h=
86+
ttp://test.com</a></p>
87+
<p><a href=3D"http://test.com/settings/notifications" style=3D"colo=
88+
r: #2563eb; text-decoration: none;">Click here to manage your notification =
89+
settings</a></p>
90+
<p><a href=3D"http://test.com/settings/notifications?disabled=3Df40=
91+
fae84-55a2-42cd-99fa-b41c1ca64894" style=3D"color: #2563eb; text-decoration=
92+
: none;">Stop receiving emails like this</a></p>
93+
</div>
94+
</div>
95+
</body>
96+
</html>
97+
98+
--bbe61b741255b6098bb6b3c1f41b885773df633cb18d2a3002b68e4bc9c4--
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"_version": "1.1",
3+
"msg_id": "00000000-0000-0000-0000-000000000000",
4+
"payload": {
5+
"_version": "1.1",
6+
"notification_name": "Template Deprecated",
7+
"notification_template_id": "00000000-0000-0000-0000-000000000000",
8+
"user_id": "00000000-0000-0000-0000-000000000000",
9+
"user_email": "bobby@coder.com",
10+
"user_name": "Bobby",
11+
"user_username": "bobby",
12+
"actions": [
13+
{
14+
"label": "See affected workspaces",
15+
"url": "http://test.com/workspaces?filter=owner%3Ame+template%3Aalpha"
16+
},
17+
{
18+
"label": "View template",
19+
"url": "http://test.com/templates/coder/alpha"
20+
}
21+
],
22+
"labels": {
23+
"message": "This template has been replaced by beta",
24+
"organization": "coder",
25+
"template": "alpha"
26+
},
27+
"data": null
28+
},
29+
"title": "Template 'alpha' has been deprecated",
30+
"title_markdown": "Template 'alpha' has been deprecated",
31+
"body": "Hello Bobby,\n\nThe template alpha has been deprecated with the following message:\n\nThis template has been replaced by beta\n\nNew workspaces may not be created from this template. Existing workspaces will continue to function normally.",
32+
"body_markdown": "Hello Bobby,\n\nThe template **alpha** has been deprecated with the following message:\n\n**This template has been replaced by beta**\n\nNew workspaces may not be created from this template. Existing workspaces will continue to function normally."
33+
}

coderd/tailnet.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,15 @@ func NewServerTailnet(
9191
})
9292
}
9393

94-
derpMapUpdaterClosed := make(chan struct{})
94+
bgRoutines := &sync.WaitGroup{}
9595
originalDerpMap := derpMapFn()
9696
// it's important to set the DERPRegionDialer above _before_ we set the DERP map so that if
9797
// there is an embedded relay, we use the local in-memory dialer.
9898
conn.SetDERPMap(originalDerpMap)
99+
bgRoutines.Add(1)
99100
go func() {
100-
defer close(derpMapUpdaterClosed)
101+
defer bgRoutines.Done()
102+
defer logger.Debug(ctx, "polling DERPMap exited")
101103

102104
ticker := time.NewTicker(5 * time.Second)
103105
defer ticker.Stop()
@@ -120,7 +122,7 @@ func NewServerTailnet(
120122
tn := &ServerTailnet{
121123
ctx: serverCtx,
122124
cancel: cancel,
123-
derpMapUpdaterClosed: derpMapUpdaterClosed,
125+
bgRoutines: bgRoutines,
124126
logger: logger,
125127
tracer: traceProvider.Tracer(tracing.TracerName),
126128
conn: conn,
@@ -170,8 +172,15 @@ func NewServerTailnet(
170172
// registering the callback also triggers send of the initial node
171173
tn.coordinatee.SetNodeCallback(tn.nodeCallback)
172174

173-
go tn.watchAgentUpdates()
174-
go tn.expireOldAgents()
175+
tn.bgRoutines.Add(2)
176+
go func() {
177+
defer tn.bgRoutines.Done()
178+
tn.watchAgentUpdates()
179+
}()
180+
go func() {
181+
defer tn.bgRoutines.Done()
182+
tn.expireOldAgents()
183+
}()
175184
return tn, nil
176185
}
177186

@@ -204,6 +213,7 @@ func (s *ServerTailnet) Collect(metrics chan<- prometheus.Metric) {
204213
}
205214

206215
func (s *ServerTailnet) expireOldAgents() {
216+
defer s.logger.Debug(s.ctx, "stopped expiring old agents")
207217
const (
208218
tick = 5 * time.Minute
209219
cutoff = 30 * time.Minute
@@ -255,6 +265,7 @@ func (s *ServerTailnet) doExpireOldAgents(cutoff time.Duration) {
255265
}
256266

257267
func (s *ServerTailnet) watchAgentUpdates() {
268+
defer s.logger.Debug(s.ctx, "stopped watching agent updates")
258269
for {
259270
conn := s.getAgentConn()
260271
resp, ok := conn.NextUpdate(s.ctx)
@@ -317,9 +328,9 @@ func (s *ServerTailnet) reinitCoordinator() {
317328
}
318329

319330
type ServerTailnet struct {
320-
ctx context.Context
321-
cancel func()
322-
derpMapUpdaterClosed chan struct{}
331+
ctx context.Context
332+
cancel func()
333+
bgRoutines *sync.WaitGroup
323334

324335
logger slog.Logger
325336
tracer trace.Tracer
@@ -532,10 +543,12 @@ func (c *netConnCloser) Close() error {
532543
}
533544

534545
func (s *ServerTailnet) Close() error {
546+
s.logger.Info(s.ctx, "closing server tailnet")
547+
defer s.logger.Debug(s.ctx, "server tailnet close complete")
535548
s.cancel()
536549
_ = s.conn.Close()
537550
s.transport.CloseIdleConnections()
538-
<-s.derpMapUpdaterClosed
551+
s.bgRoutines.Wait()
539552
return nil
540553
}
541554

0 commit comments

Comments
 (0)