Skip to content

fix(srv6): stop leaking a goroutine per EgressPolicy Watch() retry#27

Merged
ryskn merged 1 commit into
dev/srv6egress-v1from
fix/srv6-watcher-goroutine-leak
Jul 3, 2026
Merged

fix(srv6): stop leaking a goroutine per EgressPolicy Watch() retry#27
ryskn merged 1 commit into
dev/srv6egress-v1from
fix/srv6-watcher-goroutine-leak

Conversation

@ryskn

@ryskn ryskn commented Jul 3, 2026

Copy link
Copy Markdown
Owner

What

The go func(){ <-t.Dying(); cancel() }() helper blocked on t.Dying() whenever Watch returned for a non-shutdown reason (List/Watch error, result channel closed). The caller re-invokes Watch() in a loop, so an API-server outage leaked one goroutine per retry (~720/hour).

Fix

select on ctx.Done() as well, so the deferred cancel() unblocks the helper on every return.

Review finding

Low (concurrency) C1.

Test

go test ./calico-vpp-agent/srv6egress/... + GOOS=linux go vet green.

The 'go func(){ <-t.Dying(); cancel() }()' helper blocked on t.Dying()
whenever Watch returned for a non-shutdown reason (List/Watch error,
result channel closed). The caller re-invokes Watch() in a loop, so an
API-server outage leaked one goroutine per retry (~720/hour). Select on
ctx.Done() as well so the deferred cancel() unblocks it on every return.
@ryskn ryskn merged commit b0a6219 into dev/srv6egress-v1 Jul 3, 2026
1 check passed
@ryskn ryskn deleted the fix/srv6-watcher-goroutine-leak branch July 3, 2026 01:33
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