Skip to content

Fix data race in Linux compress maintainer tests#2

Merged
antoninbas merged 1 commit into
antrea-io:v2.0from
antoninbas:fix-compress-maintain-race
Jun 3, 2026
Merged

Fix data race in Linux compress maintainer tests#2
antoninbas merged 1 commit into
antrea-io:v2.0from
antoninbas:fix-compress-maintain-race

Conversation

@antoninbas

Copy link
Copy Markdown

Summary

CI failed on v2.0 with a data race in TestCompressMaintainOwner (and the same latent issue exists in TestCompressMaintainMode). These tests are Linux-only (//go:build linux), so the race only surfaces on the Ubuntu CI runner and not on a macOS development machine.

Both tests trigger a rotation, then waited for the background compression goroutine with a fixed <-time.After(10ms) sleep before reading state that the goroutine writes — the fakeFS owner map and the compressed output file. The sleep establishes no happens-before relationship with the goroutine, so the -race detector correctly flags concurrent access to the fakeFS map.

The fix replaces the sleep with l.Close(). Since Close now flushes the pending compression and joins the mill goroutine (via a WaitGroup), it both guarantees the compression has run and synchronizes the goroutine's writes with the assertions that follow. This removes the race and makes the tests deterministic instead of relying on a timing window.

Verified by running the full test suite with -race on golang:1.26 (Linux), and golangci-lint with GOOS=linux; both pass.

Made with Cursor

TestCompressMaintainOwner and TestCompressMaintainMode waited for the
background compression goroutine with a fixed sleep before reading
state it writes (the fakeFS owner map and the compressed file). The
sleep established no happens-before relationship, so the race detector
reported a data race on Linux, where these tests run.

Replace the sleep with l.Close(), which now flushes the pending
compression and joins the mill goroutine, synchronizing its writes
with the subsequent assertions. This also makes the tests
deterministic rather than relying on a timing window.

Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@antoninbas antoninbas merged commit 2fb47fc into antrea-io:v2.0 Jun 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant