fix pilot ads goroutine leak and memory leak#10862
fix pilot ads goroutine leak and memory leak#10862pxzero wants to merge 3 commits intoistio:release-1.1from
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pxzero If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @pxzero. Thanks for your PR. I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
pilot/pkg/proxy/envoy/v2/ads.go
Outdated
| reqChannel <- req | ||
| select { | ||
| case <-controlChannel: | ||
| adsLog.Errorf("ADS: %q %s stream has closed", con.PeerAddr, con.ConID) |
There was a problem hiding this comment.
This function doesn't return any status, so I'd assume that even if it was an error, it could be logged by the code that caused the channel to be closed and here we'd simply return.
pilot/pkg/proxy/envoy/v2/ads.go
Outdated
| <-reqChannel | ||
| } | ||
| }() | ||
| go receiveThread(con, reqChannel, &receiveError, controlChannel) |
There was a problem hiding this comment.
Instead of passing another controlChannel why not simply close the reqChannel and catch this on the other side?
There was a problem hiding this comment.
emm...i'm a fresher to golang . i will try it.
thanks for reply
There was a problem hiding this comment.
yes , i have try code like this. It is simply but not easy to understand the mean of panic recover. maybe using a control channel can be more readable ?
func receiveThread(con *XdsConnection, reqChannel chan *xdsapi.DiscoveryRequest, errP *error) {
defer close(reqChannel) // indicates close of the remote side.
defer func() {
if r := recover(); r != nil {
err, ok := r.(error)
if ok {
errP = &err
}
}
}()
for {
req, err := con.stream.Recv()
if err != nil {
if status.Code(err) == codes.Canceled || err == io.EOF {
con.mu.RLock()
adsLog.Infof("ADS: %q %s terminated %v", con.PeerAddr, con.ConID, err)
con.mu.RUnlock()
return
}
*errP = err
adsLog.Errorf("ADS: %q %s terminated with errors %v", con.PeerAddr, con.ConID, err)
totalXDSInternalErrors.Add(1)
return
}
reqChannel <- req
}
}There was a problem hiding this comment.
There's already con.doneChannel that's closed when StreamAggregatedResources returns, seems you could use that in receiveThread. Seems simpler and cleaner than abusing panic recovery.
There was a problem hiding this comment.
greet . use doneChannel is awesome!
|
@pxzero: PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
For #10822
commit PR to branch release 1.1