Skip to content

Commit c2b27c3

Browse files
committed
Merge remote-tracking branch 'origin/main' into quickstart-guide
2 parents 7e6c079 + 416d67b commit c2b27c3

Some content is hidden

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

44 files changed

+508
-163
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: |
44
inputs:
55
version:
66
description: "The Go version to use."
7-
default: "1.22.5"
7+
default: "1.22.6"
88
runs:
99
using: "composite"
1010
steps:

.github/workflows/mlc_config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
{
1313
"pattern": "docs.github.com"
1414
},
15+
{
16+
"pattern": "github.com/<your_github_handle>"
17+
},
18+
{
19+
"pattern": "imgur.com"
20+
},
1521
{
1622
"pattern": "support.google.com"
1723
},

.github/workflows/security.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
echo "image=$(cat "$image_job")" >> $GITHUB_OUTPUT
115115
116116
- name: Run Trivy vulnerability scanner
117-
uses: aquasecurity/trivy-action@f781cce5aab226378ee181d764ab90ea0be3cdd8
117+
uses: aquasecurity/trivy-action@5681af892cd0f4997658e2bacc62bd0a894cf564
118118
with:
119119
image-ref: ${{ steps.build.outputs.image }}
120120
format: sarif

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ gen: \
507507
examples/examples.gen.json \
508508
tailnet/tailnettest/coordinatormock.go \
509509
tailnet/tailnettest/coordinateemock.go \
510-
tailnet/tailnettest/multiagentmock.go
510+
tailnet/tailnettest/multiagentmock.go \
511+
coderd/database/pubsub/psmock/psmock.go
511512
.PHONY: gen
512513

513514
# Mark all generated files as fresh so make thinks they're up-to-date. This is
@@ -537,6 +538,7 @@ gen/mark-fresh:
537538
tailnet/tailnettest/coordinatormock.go \
538539
tailnet/tailnettest/coordinateemock.go \
539540
tailnet/tailnettest/multiagentmock.go \
541+
coderd/database/pubsub/psmock/psmock.go \
540542
"
541543

542544
for file in $$files; do

agent/agent.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
16701670
}
16711671

16721672
score, niceErr := proc.Niceness(a.syscaller)
1673-
if !isBenignProcessErr(niceErr) {
1673+
if niceErr != nil && !isBenignProcessErr(niceErr) {
16741674
debouncer.Warn(ctx, "unable to get proc niceness",
16751675
slog.F("cmd", proc.Cmd()),
16761676
slog.F("pid", proc.PID),
@@ -1689,7 +1689,7 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
16891689

16901690
if niceErr == nil {
16911691
err := proc.SetNiceness(a.syscaller, niceness)
1692-
if !isBenignProcessErr(err) {
1692+
if err != nil && !isBenignProcessErr(err) {
16931693
debouncer.Warn(ctx, "unable to set proc niceness",
16941694
slog.F("cmd", proc.Cmd()),
16951695
slog.F("pid", proc.PID),
@@ -1703,7 +1703,7 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
17031703
if oomScore != unsetOOMScore && oomScore != proc.OOMScoreAdj && !isCustomOOMScore(agentScore, proc) {
17041704
oomScoreStr := strconv.Itoa(oomScore)
17051705
err := afero.WriteFile(a.filesystem, fmt.Sprintf("/proc/%d/oom_score_adj", proc.PID), []byte(oomScoreStr), 0o644)
1706-
if !isBenignProcessErr(err) {
1706+
if err != nil && !isBenignProcessErr(err) {
17071707
debouncer.Warn(ctx, "unable to set oom_score_adj",
17081708
slog.F("cmd", proc.Cmd()),
17091709
slog.F("pid", proc.PID),

cli/testdata/coder_templates_init_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ USAGE:
66
Get started with a templated template.
77

88
OPTIONS:
9-
--id aws-devcontainer|aws-linux|aws-windows|azure-linux|do-linux|docker|gcp-devcontainer|gcp-linux|gcp-vm-container|gcp-windows|kubernetes|nomad-docker|scratch
9+
--id aws-devcontainer|aws-linux|aws-windows|azure-linux|devcontainer-docker|devcontainer-kubernetes|do-linux|docker|gcp-devcontainer|gcp-linux|gcp-vm-container|gcp-windows|kubernetes|nomad-docker|scratch
1010
Specify a given example template by ID.
1111

1212
———
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
UPDATE notification_templates
2+
SET
3+
body_template = E'Hi {{.UserName}},\n\n' ||
4+
E'A manual build of the workspace **{{.Labels.name}}** using the template **{{.Labels.template_name}}** failed (version: **{{.Labels.template_version_name}}**).\n\n' ||
5+
-- Mention template display name:
6+
E'The template''s display name was **{{.Labels.template_display_name}}**. ' ||
7+
E'The workspace build was initiated by **{{.Labels.initiator}}**.'
8+
WHERE
9+
id = '2faeee0f-26cb-4e96-821c-85ccb9f71513';
10+
11+
UPDATE notification_templates
12+
SET
13+
body_template = E'Hi {{.UserName}},\n\n' || -- Add a comma
14+
E'The template **{{.Labels.name}}** was deleted by **{{ .Labels.initiator }}**.\n\n' ||
15+
-- Mention template display name:
16+
E'The template''s display name was **{{.Labels.display_name}}**.'
17+
WHERE
18+
id = '29a09665-2a4c-403f-9648-54301670e7be';
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
UPDATE notification_templates
2+
SET
3+
body_template = E'Hi {{.UserName}},\n\n' ||
4+
-- Revert to a single label for the template name:
5+
E'A manual build of the workspace **{{.Labels.name}}** using the template **{{.Labels.template_name}}** failed (version: **{{.Labels.template_version_name}}**).\n\n' ||
6+
E'The workspace build was initiated by **{{.Labels.initiator}}**.'
7+
WHERE
8+
id = '2faeee0f-26cb-4e96-821c-85ccb9f71513';
9+
10+
UPDATE notification_templates
11+
SET
12+
body_template = E'Hi {{.UserName}},\n\n' ||
13+
-- Revert to a single label for the template name:
14+
E'The template **{{.Labels.name}}** was deleted by **{{ .Labels.initiator }}**.\n\n'
15+
WHERE
16+
id = '29a09665-2a4c-403f-9648-54301670e7be';

coderd/insights_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func TestUserLatencyInsights(t *testing.T) {
225225
t.Parallel()
226226

227227
db, ps := dbtestutil.NewDB(t)
228-
logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: false}).Leveled(slog.LevelDebug)
228+
logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug)
229229
client := coderdtest.New(t, &coderdtest.Options{
230230
Database: db,
231231
Pubsub: ps,

coderd/notifications/metrics_test.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package notifications_test
33
import (
44
"context"
55
"strconv"
6+
"sync"
67
"testing"
78
"time"
89

@@ -317,10 +318,12 @@ func TestInflightDispatchesMetric(t *testing.T) {
317318
})
318319

319320
handler := &fakeHandler{}
320-
// Delayer will delay all dispatches by 2x fetch intervals to ensure we catch the requests inflight.
321-
delayer := newDelayingHandler(cfg.FetchInterval.Value()*2, handler)
321+
const msgCount = 2
322+
323+
// Barrier handler will wait until all notification messages are in-flight.
324+
barrier := newBarrierHandler(msgCount, handler)
322325
mgr.WithHandlers(map[database.NotificationMethod]notifications.Handler{
323-
method: delayer,
326+
method: barrier,
324327
})
325328

326329
enq, err := notifications.NewStoreEnqueuer(cfg, api.Database, defaultHelpers(), api.Logger.Named("enqueuer"), quartz.NewReal())
@@ -329,7 +332,6 @@ func TestInflightDispatchesMetric(t *testing.T) {
329332
user := createSampleUser(t, api.Database)
330333

331334
// WHEN: notifications are enqueued which will succeed (and be delayed during dispatch)
332-
const msgCount = 2
333335
for i := 0; i < msgCount; i++ {
334336
_, err = enq.Enqueue(ctx, user.ID, template, map[string]string{"type": "success", "i": strconv.Itoa(i)}, "test")
335337
require.NoError(t, err)
@@ -343,6 +345,10 @@ func TestInflightDispatchesMetric(t *testing.T) {
343345
return promtest.ToFloat64(metrics.InflightDispatches.WithLabelValues(string(method), template.String())) == msgCount
344346
}, testutil.WaitShort, testutil.IntervalFast)
345347

348+
for i := 0; i < msgCount; i++ {
349+
barrier.wg.Done()
350+
}
351+
346352
// Wait until the handler has dispatched the given notifications.
347353
require.Eventually(t, func() bool {
348354
handler.mu.RLock()
@@ -493,27 +499,30 @@ func (u *updateSignallingInterceptor) BulkMarkNotificationMessagesFailed(ctx con
493499
return u.Store.BulkMarkNotificationMessagesFailed(ctx, arg)
494500
}
495501

496-
type delayingHandler struct {
502+
type barrierHandler struct {
497503
h notifications.Handler
498504

499-
delay time.Duration
505+
wg *sync.WaitGroup
500506
}
501507

502-
func newDelayingHandler(delay time.Duration, handler notifications.Handler) *delayingHandler {
503-
return &delayingHandler{
504-
delay: delay,
505-
h: handler,
508+
func newBarrierHandler(total int, handler notifications.Handler) *barrierHandler {
509+
var wg sync.WaitGroup
510+
wg.Add(total)
511+
512+
return &barrierHandler{
513+
h: handler,
514+
wg: &wg,
506515
}
507516
}
508517

509-
func (d *delayingHandler) Dispatcher(payload types.MessagePayload, title, body string) (dispatch.DeliveryFunc, error) {
510-
deliverFn, err := d.h.Dispatcher(payload, title, body)
518+
func (bh *barrierHandler) Dispatcher(payload types.MessagePayload, title, body string) (dispatch.DeliveryFunc, error) {
519+
deliverFn, err := bh.h.Dispatcher(payload, title, body)
511520
if err != nil {
512521
return nil, err
513522
}
514523

515524
return func(ctx context.Context, msgID uuid.UUID) (retryable bool, err error) {
516-
time.Sleep(d.delay)
525+
bh.wg.Wait()
517526

518527
return deliverFn(ctx, msgID)
519528
}, nil

0 commit comments

Comments
 (0)