-
Notifications
You must be signed in to change notification settings - Fork 707
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
Ensure Elasticsearch client is closed after each reconciliation #8175
Ensure Elasticsearch client is closed after each reconciliation #8175
Conversation
Signed-off-by: Michael Montgomery <mmontg1@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great finding. I am still a bit confused how this slipped through. I think you have to adjust the fake client too to not panic when close is called
github.com/elastic/cloud-on-k8s/v2/pkg/controller/autoscaling/elasticsearch.(*fakeEsClient).Close(0xc00095c700?)
Add close func to fake esclient struct. Signed-off-by: Michael Montgomery <mmontg1@gmail.com>
Signed-off-by: Michael Montgomery <mmontg1@gmail.com>
Signs from initial testing of the latest build show good signs, as the memory seems stable. I'm going to let it run the rest of the day to ensure before merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Find!
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
* Ensure esclient is closed after each reconcile. * Also call close in stackconfigpolicy. * Add close func to fake esclient struct. * Also add close to fakeseClient in stackconfigpolicy --------- Signed-off-by: Michael Montgomery <mmontg1@gmail.com> (cherry picked from commit 602866e)
* Ensure esclient is closed after each reconcile. * Also call close in stackconfigpolicy. * Add close func to fake esclient struct. * Also add close to fakeseClient in stackconfigpolicy --------- Signed-off-by: Michael Montgomery <mmontg1@gmail.com> (cherry picked from commit 602866e)
Resolves #8174
While investigating #8174 a couple pprof heap dumps were taken over the course of a couple of days, and compared using the diff capabilities of pprof:
This brought to light the following function in the autoscaling controller (
attemptOnlineReconciliation
), which seems to have had it's heap allocations grow by about %2000 since the first dump:Upon further investigation, we don't appear to be closing idle connections in the underlying http client, which could be leaking goroutines, and therefore leading to this memory increase.