Skip to content

Commit

Permalink
roachtest: fix TestVMPreemptionPolling data race
Browse files Browse the repository at this point in the history
This changes monitorForPreemptedVMs to read pollPreemptionInterval
just once, so when unit tests change the value we don't run into
concurrent access.

Fixes: #135267
Epic: none
Release note: none
  • Loading branch information
DarrylWong committed Nov 15, 2024
1 parent d72000b commit 3b0e46f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/cmd/roachtest/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2139,13 +2139,14 @@ func monitorForPreemptedVMs(ctx context.Context, t test.Test, c cluster.Cluster,
if c.IsLocal() || !c.Spec().UseSpotVMs {
return
}
interval := pollPreemptionInterval

go func() {
for {
select {
case <-ctx.Done():
return
case <-time.After(pollPreemptionInterval):
case <-time.After(interval):
preemptedVMs, err := getPreemptedVMsHook(c, ctx, l)
if err != nil {
l.Printf("WARN: monitorForPreemptedVMs: failed to check preempted VMs:\n%+v", err)
Expand Down

0 comments on commit 3b0e46f

Please sign in to comment.