S01 follow-up: remove TestMain sink workaround once LabKit v2.8.0 signal-handler fix lands
Context
MR !291, note 3382835815 documents a LabKit v2.8.0 race in app.Run: signal.Notify is called only after a.Start returns (app.go#L469-L484). A SIGTERM in that window has no Go handler and the OS kills the binary.
AR works around this in cmd/artifact-registry/main_test.go with:
- A
TestMainsink (cap=1 channel registered withsignal.Notify) that keeps a Go handler in place so the OS does not kill the test process. - A
keepSignallinghelper that re-fires the signal every 100ms. Go's signal package fans each signal to every registered channel independently, so the retry lands on LabKit's channel as soon asapp.Runinstalls it.
We should ask the LabKit team in the MR thread to consider moving signal.Notify inside a.Start so the handler is in place before Start returns. Upstream tracker TBD.
When to revisit
Once LabKit ships a fix:
- Drop the
TestMainsink installation incmd/artifact-registry/main_test.go. - Replace
keepSignalling(t, syscall.SIGTERM)call sites with a directsyscall.Kill(os.Getpid(), syscall.SIGTERM). - Remove the
keepSignallinghelper. - Trim the workaround narrative from the test file's package doc and related comments.
Related
- #100 (closed): LabKit
Addr()/ProbeAddr()race in the sameServer.Startpath; fixed by labkit!504. - MR !291 (merged): S01 Step 6 composition root, where the workaround landed.
Edited by João Pereira