Skip to content

Commit e50516d

Browse files
Merge remote-tracking branch 'origin/main' into 17988-metric-for-hard-limited-presets
2 parents 690d8e8 + 8f44603 commit e50516d

File tree

69 files changed

+387
-314
lines changed

Some content is hidden

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

69 files changed

+387
-314
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ jobs:
335335
# a separate repository to allow its use before actions/checkout.
336336
- name: Setup RAM Disks
337337
if: runner.os == 'Windows'
338-
uses: coder/setup-ramdisk-action@a4b59caa8be2e88c348abeef042d7c1a33d8743e
338+
uses: coder/setup-ramdisk-action@e1100847ab2d7bcd9d14bcda8f2d1b0f07b36f1b
339339

340340
- name: Checkout
341341
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -436,7 +436,7 @@ jobs:
436436
# a separate repository to allow its use before actions/checkout.
437437
- name: Setup RAM Disks
438438
if: runner.os == 'Windows'
439-
uses: coder/setup-ramdisk-action@a4b59caa8be2e88c348abeef042d7c1a33d8743e
439+
uses: coder/setup-ramdisk-action@e1100847ab2d7bcd9d14bcda8f2d1b0f07b36f1b
440440

441441
- name: Checkout
442442
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

agent/agentcontainers/api_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func TestAPI(t *testing.T) {
257257

258258
// Make sure the ticker function has been registered
259259
// before advancing the clock.
260-
tickerTrap.MustWait(ctx).Release()
260+
tickerTrap.MustWait(ctx).MustRelease(ctx)
261261
tickerTrap.Close()
262262

263263
// Initial request returns the initial data.
@@ -432,7 +432,7 @@ func TestAPI(t *testing.T) {
432432

433433
// Make sure the ticker function has been registered
434434
// before advancing the clock.
435-
tickerTrap.MustWait(ctx).Release()
435+
tickerTrap.MustWait(ctx).MustRelease(ctx)
436436
tickerTrap.Close()
437437

438438
for i := range tt.wantStatus {
@@ -486,7 +486,7 @@ func TestAPI(t *testing.T) {
486486
nowRecreateSuccessTrap.Close()
487487
// The timestamp for the error will be stored, which gives
488488
// us a good anchor point to know when to do our request.
489-
nowRecreateErrorTrap.MustWait(ctx).Release()
489+
nowRecreateErrorTrap.MustWait(ctx).MustRelease(ctx)
490490
nowRecreateErrorTrap.Close()
491491

492492
// Advance the clock to run the devcontainer state update routine.
@@ -507,7 +507,7 @@ func TestAPI(t *testing.T) {
507507
}
508508

509509
// Ensure the devcontainer ends up in success state.
510-
nowRecreateSuccessTrap.MustWait(ctx).Release()
510+
nowRecreateSuccessTrap.MustWait(ctx).MustRelease(ctx)
511511
nowRecreateSuccessTrap.Close()
512512

513513
// Advance the clock to run the devcontainer state update routine.
@@ -911,7 +911,7 @@ func TestAPI(t *testing.T) {
911911

912912
// Make sure the ticker function has been registered
913913
// before advancing any use of mClock.Advance.
914-
tickerTrap.MustWait(ctx).Release()
914+
tickerTrap.MustWait(ctx).MustRelease(ctx)
915915
tickerTrap.Close()
916916

917917
// Make sure the start loop has been called.
@@ -1007,7 +1007,7 @@ func TestAPI(t *testing.T) {
10071007

10081008
// Make sure the ticker function has been registered
10091009
// before advancing any use of mClock.Advance.
1010-
tickerTrap.MustWait(ctx).Release()
1010+
tickerTrap.MustWait(ctx).MustRelease(ctx)
10111011
tickerTrap.Close()
10121012

10131013
// Call the list endpoint first to ensure config files are

agent/apphealth_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestAppHealth_Healthy(t *testing.T) {
7878
healthchecksStarted := make([]string, 2)
7979
for i := 0; i < 2; i++ {
8080
c := healthcheckTrap.MustWait(ctx)
81-
c.Release()
81+
c.MustRelease(ctx)
8282
healthchecksStarted[i] = c.Tags[1]
8383
}
8484
slices.Sort(healthchecksStarted)
@@ -87,7 +87,7 @@ func TestAppHealth_Healthy(t *testing.T) {
8787
// advance the clock 1ms before the report ticker starts, so that it's not
8888
// simultaneous with the checks.
8989
mClock.Advance(time.Millisecond).MustWait(ctx)
90-
reportTrap.MustWait(ctx).Release()
90+
reportTrap.MustWait(ctx).MustRelease(ctx)
9191

9292
mClock.Advance(999 * time.Millisecond).MustWait(ctx) // app2 is now healthy
9393

@@ -143,11 +143,11 @@ func TestAppHealth_500(t *testing.T) {
143143

144144
fakeAPI, closeFn := setupAppReporter(ctx, t, slices.Clone(apps), handlers, mClock)
145145
defer closeFn()
146-
healthcheckTrap.MustWait(ctx).Release()
146+
healthcheckTrap.MustWait(ctx).MustRelease(ctx)
147147
// advance the clock 1ms before the report ticker starts, so that it's not
148148
// simultaneous with the checks.
149149
mClock.Advance(time.Millisecond).MustWait(ctx)
150-
reportTrap.MustWait(ctx).Release()
150+
reportTrap.MustWait(ctx).MustRelease(ctx)
151151

152152
mClock.Advance(999 * time.Millisecond).MustWait(ctx) // check gets triggered
153153
mClock.Advance(time.Millisecond).MustWait(ctx) // report gets triggered, but unsent since we are at the threshold
@@ -202,25 +202,25 @@ func TestAppHealth_Timeout(t *testing.T) {
202202

203203
fakeAPI, closeFn := setupAppReporter(ctx, t, apps, handlers, mClock)
204204
defer closeFn()
205-
healthcheckTrap.MustWait(ctx).Release()
205+
healthcheckTrap.MustWait(ctx).MustRelease(ctx)
206206
// advance the clock 1ms before the report ticker starts, so that it's not
207207
// simultaneous with the checks.
208208
mClock.Set(ms(1)).MustWait(ctx)
209-
reportTrap.MustWait(ctx).Release()
209+
reportTrap.MustWait(ctx).MustRelease(ctx)
210210

211211
w := mClock.Set(ms(1000)) // 1st check starts
212-
timeoutTrap.MustWait(ctx).Release()
212+
timeoutTrap.MustWait(ctx).MustRelease(ctx)
213213
mClock.Set(ms(1001)).MustWait(ctx) // report tick, no change
214214
mClock.Set(ms(1999)) // timeout pops
215215
w.MustWait(ctx) // 1st check finished
216216
w = mClock.Set(ms(2000)) // 2nd check starts
217-
timeoutTrap.MustWait(ctx).Release()
217+
timeoutTrap.MustWait(ctx).MustRelease(ctx)
218218
mClock.Set(ms(2001)).MustWait(ctx) // report tick, no change
219219
mClock.Set(ms(2999)) // timeout pops
220220
w.MustWait(ctx) // 2nd check finished
221221
// app is now unhealthy after 2 timeouts
222222
mClock.Set(ms(3000)) // 3rd check starts
223-
timeoutTrap.MustWait(ctx).Release()
223+
timeoutTrap.MustWait(ctx).MustRelease(ctx)
224224
mClock.Set(ms(3001)).MustWait(ctx) // report tick, sends changes
225225

226226
update := testutil.TryReceive(ctx, t, fakeAPI.AppHealthCh())

cli/ssh_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func TestCloserStack_Timeout(t *testing.T) {
206206
defer close(closed)
207207
uut.close(nil)
208208
}()
209-
trap.MustWait(ctx).Release()
209+
trap.MustWait(ctx).MustRelease(ctx)
210210
// top starts right away, but it hangs
211211
testutil.TryReceive(ctx, t, ac[2].started)
212212
// timer pops and we start the middle one

coderd/autobuild/notify/notifier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestNotifier(t *testing.T) {
104104
n := notify.New(cond, testCase.PollInterval, testCase.Countdown, notify.WithTestClock(mClock))
105105
defer n.Close()
106106

107-
trap.MustWait(ctx).Release() // ensure ticker started
107+
trap.MustWait(ctx).MustRelease(ctx) // ensure ticker started
108108
for i := 0; i < testCase.NTicks; i++ {
109109
interval, w := mClock.AdvanceNext()
110110
w.MustWait(ctx)

coderd/cryptokeys/cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ func TestCryptoKeyCache(t *testing.T) {
423423
require.Equal(t, 2, ff.called)
424424
require.Equal(t, decodedSecret(t, newKey), key)
425425

426-
trapped.Release()
426+
trapped.MustRelease(ctx)
427427
wait.MustWait(ctx)
428428
require.Equal(t, 2, ff.called)
429429
trap.Close()

coderd/cryptokeys/rotate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestRotator(t *testing.T) {
7272
require.Len(t, dbkeys, initialKeyLen)
7373
requireContainsAllFeatures(t, dbkeys)
7474

75-
trap.MustWait(ctx).Release()
75+
trap.MustWait(ctx).MustRelease(ctx)
7676
_, wait := clock.AdvanceNext()
7777
wait.MustWait(ctx)
7878

coderd/database/dbpurge/dbpurge_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,18 @@ func awaitDoTick(ctx context.Context, t *testing.T, clk *quartz.Mock) chan struc
279279
defer trapStop.Close()
280280
defer trapNow.Close()
281281
// Wait for the initial tick signified by a call to Now().
282-
trapNow.MustWait(ctx).Release()
282+
trapNow.MustWait(ctx).MustRelease(ctx)
283283
// doTick runs here. Wait for the next
284284
// ticker reset event that signifies it's completed.
285-
trapReset.MustWait(ctx).Release()
285+
trapReset.MustWait(ctx).MustRelease(ctx)
286286
// Ensure that the next tick happens in 10 minutes from start.
287287
d, w := clk.AdvanceNext()
288288
if !assert.Equal(t, 10*time.Minute, d) {
289289
return
290290
}
291291
w.MustWait(ctx)
292292
// Wait for the ticker stop event.
293-
trapStop.MustWait(ctx).Release()
293+
trapStop.MustWait(ctx).MustRelease(ctx)
294294
}()
295295

296296
return ch

coderd/database/pubsub/watchdog_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestWatchdog_NoTimeout(t *testing.T) {
3232
// right baseline time.
3333
pc, err := pubTrap.Wait(ctx)
3434
require.NoError(t, err)
35-
pc.Release()
35+
pc.MustRelease(ctx)
3636
require.Equal(t, 15*time.Second, pc.Duration)
3737

3838
// we subscribe after starting the timer, so we know the timer also starts
@@ -66,7 +66,7 @@ func TestWatchdog_NoTimeout(t *testing.T) {
6666
}()
6767
sc, err := subTrap.Wait(ctx) // timer.Stop() called
6868
require.NoError(t, err)
69-
sc.Release()
69+
sc.MustRelease(ctx)
7070
err = testutil.TryReceive(ctx, t, errCh)
7171
require.NoError(t, err)
7272
}
@@ -88,7 +88,7 @@ func TestWatchdog_Timeout(t *testing.T) {
8888
// right baseline time.
8989
pc, err := pubTrap.Wait(ctx)
9090
require.NoError(t, err)
91-
pc.Release()
91+
pc.MustRelease(ctx)
9292
require.Equal(t, 15*time.Second, pc.Duration)
9393

9494
// we subscribe after starting the timer, so we know the timer also starts

coderd/notifications/metrics_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ func TestPendingUpdatesMetric(t *testing.T) {
276276
require.NoError(t, err)
277277

278278
mgr.Run(ctx)
279-
trap.MustWait(ctx).Release() // ensures ticker has been set
280-
fetchTrap.MustWait(ctx).Release()
279+
trap.MustWait(ctx).MustRelease(ctx) // ensures ticker has been set
280+
fetchTrap.MustWait(ctx).MustRelease(ctx)
281281

282282
// Advance to the first fetch
283283
mClock.Advance(cfg.FetchInterval.Value()).MustWait(ctx)

coderd/notifications/notifications_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ func TestBackpressure(t *testing.T) {
341341

342342
// Start the notifier.
343343
mgr.Run(ctx)
344-
syncTrap.MustWait(ctx).Release()
345-
fetchTrap.MustWait(ctx).Release()
344+
syncTrap.MustWait(ctx).MustRelease(ctx)
345+
fetchTrap.MustWait(ctx).MustRelease(ctx)
346346

347347
// THEN:
348348

enterprise/coderd/prebuilds/reconcile_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ func TestRunLoop(t *testing.T) {
11401140
trap := clock.Trap().NewTicker()
11411141
go reconciler.Run(ctx)
11421142
// wait until ticker is initialized
1143-
trap.MustWait(ctx).Release()
1143+
trap.MustWait(ctx).MustRelease(ctx)
11441144
// start 1st iteration of ReconciliationLoop
11451145
// NOTE: at this point MustWait waits that iteration is started (ReconcileAll is called), but it doesn't wait until it completes
11461146
clock.Advance(cfg.ReconciliationInterval.Value()).MustWait(ctx)

enterprise/tailnet/pgcoord_internal_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ func TestHeartbeats_Cleanup(t *testing.T) {
6363
uut.wg.Add(1)
6464
go uut.cleanupLoop()
6565

66-
call, err := trap.Wait(ctx)
67-
require.NoError(t, err)
68-
call.Release()
66+
call := trap.MustWait(ctx)
67+
call.MustRelease(ctx)
6968
require.Equal(t, cleanupPeriod, call.Duration)
7069
mClock.Advance(cleanupPeriod).MustWait(ctx)
7170
}
@@ -99,7 +98,7 @@ func TestHeartbeats_recvBeat_resetSkew(t *testing.T) {
9998
// coord 3 heartbeat comes very soon after
10099
mClock.Advance(time.Millisecond).MustWait(ctx)
101100
go uut.listen(ctx, []byte(coord3.String()), nil)
102-
trap.MustWait(ctx).Release()
101+
trap.MustWait(ctx).MustRelease(ctx)
103102

104103
// both coordinators are present
105104
uut.lock.RLock()
@@ -112,11 +111,11 @@ func TestHeartbeats_recvBeat_resetSkew(t *testing.T) {
112111
// however, several ms pass between expiring 2 and computing the time until 3 expires
113112
c := trap.MustWait(ctx)
114113
mClock.Advance(2 * time.Millisecond).MustWait(ctx) // 3 has now expired _in the past_
115-
c.Release()
114+
c.MustRelease(ctx)
116115
w.MustWait(ctx)
117116

118117
// expired in the past means we immediately reschedule checkExpiry, so we get another call
119-
trap.MustWait(ctx).Release()
118+
trap.MustWait(ctx).MustRelease(ctx)
120119

121120
uut.lock.RLock()
122121
require.NotContains(t, uut.coordinators, coord2)
@@ -411,7 +410,7 @@ func TestPGCoordinatorUnhealthy(t *testing.T) {
411410
expectedPeriod := HeartbeatPeriod
412411
tfCall, err := tfTrap.Wait(ctx)
413412
require.NoError(t, err)
414-
tfCall.Release()
413+
tfCall.MustRelease(ctx)
415414
require.Equal(t, expectedPeriod, tfCall.Duration)
416415

417416
// Now that the ticker has started, we can advance 2 more beats to get to 3

enterprise/tailnet/pgcoord_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func TestPGCoordinatorSingle_MissedHeartbeats(t *testing.T) {
286286
}
287287

288288
fCoord2.heartbeat()
289-
afTrap.MustWait(ctx).Release() // heartbeat timeout started
289+
afTrap.MustWait(ctx).MustRelease(ctx) // heartbeat timeout started
290290

291291
fCoord2.agentNode(agent.ID, &agpl.Node{PreferredDERP: 12})
292292
client.AssertEventuallyHasDERP(agent.ID, 12)
@@ -298,20 +298,20 @@ func TestPGCoordinatorSingle_MissedHeartbeats(t *testing.T) {
298298
id: uuid.New(),
299299
}
300300
fCoord3.heartbeat()
301-
rstTrap.MustWait(ctx).Release() // timeout gets reset
301+
rstTrap.MustWait(ctx).MustRelease(ctx) // timeout gets reset
302302
fCoord3.agentNode(agent.ID, &agpl.Node{PreferredDERP: 13})
303303
client.AssertEventuallyHasDERP(agent.ID, 13)
304304

305305
// fCoord2 sends in a second heartbeat, one period later (on time)
306306
mClock.Advance(tailnet.HeartbeatPeriod).MustWait(ctx)
307307
fCoord2.heartbeat()
308-
rstTrap.MustWait(ctx).Release() // timeout gets reset
308+
rstTrap.MustWait(ctx).MustRelease(ctx) // timeout gets reset
309309

310310
// when the fCoord3 misses enough heartbeats, the real coordinator should send an update with the
311311
// node from fCoord2 for the agent.
312312
mClock.Advance(tailnet.HeartbeatPeriod).MustWait(ctx)
313313
w := mClock.Advance(tailnet.HeartbeatPeriod)
314-
rstTrap.MustWait(ctx).Release()
314+
rstTrap.MustWait(ctx).MustRelease(ctx)
315315
w.MustWait(ctx)
316316
client.AssertEventuallyHasDERP(agent.ID, 12)
317317

@@ -323,7 +323,7 @@ func TestPGCoordinatorSingle_MissedHeartbeats(t *testing.T) {
323323

324324
// send fCoord3 heartbeat, which should trigger us to consider that mapping valid again.
325325
fCoord3.heartbeat()
326-
rstTrap.MustWait(ctx).Release() // timeout gets reset
326+
rstTrap.MustWait(ctx).MustRelease(ctx) // timeout gets reset
327327
client.AssertEventuallyHasDERP(agent.ID, 13)
328328

329329
agent.UngracefulDisconnect(ctx)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ require (
9898
github.com/coder/flog v1.1.0
9999
github.com/coder/guts v1.5.0
100100
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0
101-
github.com/coder/quartz v0.1.3
101+
github.com/coder/quartz v0.2.1-0.20250527113331-b71761ce32df
102102
github.com/coder/retry v1.5.1
103103
github.com/coder/serpent v0.10.0
104104
github.com/coder/terraform-provider-coder/v2 v2.5.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,8 @@ github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 h1:3A0ES21Ke+FxEM8CXx
913913
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0/go.mod h1:5UuS2Ts+nTToAMeOjNlnHFkPahrtDkmpydBen/3wgZc=
914914
github.com/coder/preview v0.0.2-0.20250521212114-e6a60ffa74f2 h1:D52yPPupcbNWppZzWAjZJG5L34TGpNyKj7vG1VT13FU=
915915
github.com/coder/preview v0.0.2-0.20250521212114-e6a60ffa74f2/go.mod h1:9bwyhQSVDjcxAWuFFaG6/qBqhaiW5oqF5PEQMhevKLs=
916-
github.com/coder/quartz v0.1.3 h1:hA2nI8uUA2fNN9uhXv2I4xZD4aHkA7oH3g2t03v4xf8=
917-
github.com/coder/quartz v0.1.3/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA=
916+
github.com/coder/quartz v0.2.1-0.20250527113331-b71761ce32df h1:o6lpiSrGKVopPv6Fnh3S+FrI5ntRE0eSUo6Bqpzpkgo=
917+
github.com/coder/quartz v0.2.1-0.20250527113331-b71761ce32df/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA=
918918
github.com/coder/retry v1.5.1 h1:iWu8YnD8YqHs3XwqrqsjoBTAVqT9ml6z9ViJ2wlMiqc=
919919
github.com/coder/retry v1.5.1/go.mod h1:blHMk9vs6LkoRT9ZHyuZo360cufXEhrxqvEzeMtRGoY=
920920
github.com/coder/serpent v0.10.0 h1:ofVk9FJXSek+SmL3yVE3GoArP83M+1tX+H7S4t8BSuM=

0 commit comments

Comments
 (0)