Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: goroutine leak during watch leases (kube) #1799

Merged
merged 2 commits into from
Sep 18, 2023

Conversation

iiiceoo
Copy link
Contributor

@iiiceoo iiiceoo commented Aug 31, 2023

Description

In the implementation of Kubernetes API, leaseWatchChan did not close correctly after ctx cancellation:

case <-ctx.Done():
return context.Canceled
}

Will cause the following loop to not end:

for watchResults := range leaseWatchChan {
for _, wr := range watchResults {
var batch []lease.Event
if len(wr.Events) > 0 {
batch = lw.Update(wr.Events)
} else {
batch = lw.Reset(wr.Snapshot)
}
for i := range batch {
log.Infof("Batch elem [%d] is { %#v }", i, batch[i])
}
if len(batch) > 0 {
receiver <- batch
}
}
}

Todos

  • Tests
  • Documentation
  • Release note

Release Note

None required

Signed-off-by: iiiceoo [email protected]

@iiiceoo
Copy link
Contributor Author

iiiceoo commented Sep 4, 2023

When the CI was executing, an error unrelated to this PR was reported (workflow), the key logs are as follows:

I0901 14:38:03.171316    4220 subnet_test.go:451] found key: /coreos.com/network/subnets/10.3.16.0-24
    subnet_test.go:462: Failed to renew lease: bad expiration; expected 2023-09-02 14:38:05 +0000 UTC, got 2023-09-02 14:38:00 +0000 UTC
...
--- FAIL: TestRenewLease (11.04s)

This should be due to the fact that the acceptableMargin is too short and kvApi.Get(...) takes more time than acceptableMargin/2. I push another commit and fixed it by the way.

@manuelbuil manuelbuil merged commit 4d37aa7 into flannel-io:master Sep 18, 2023
8 checks passed
@iiiceoo iiiceoo deleted the fix-wl-ctx branch September 18, 2023 06:41
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.

3 participants