-
Notifications
You must be signed in to change notification settings - Fork 174
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
Prevent memory leak in headers. #252
Conversation
Signed-off-by: Tom Kelley <[email protected]>
Signed-off-by: Tom Kelley <[email protected]>
Signed-off-by: Tom Kelley <[email protected]>
This a a major issue, I'll review it tonight and release 2.23.1 with your fix if it's OK. |
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.
I quickly red your fix, and I think we should call BasicAuth()
function at client init, and not in Post()
and that will avoid to add authentication Headers at each Post, wdyt?
Something like: if config.Elasticsearch.HostPort != "" {
var err error
elasticsearchClient, err = outputs.NewClient("Elasticsearch", config.Elasticsearch.HostPort+"/"+config.Elasticsearch.Index+"/"+config.Elasticsearch.Type, config.Elasticsearch.MutualTLS, config.Elasticsearch.CheckCert, config, stats, promStats, statsdClient, dogstatsdClient)
if err != nil {
config.Elasticsearch.HostPort = ""
} else {
if config.Elasticsearch.Username != "" && config.Elasticsearch.Password != "" {
elasticsearchClientc.BasicAuth(config.Elasticsearch.Username, config.Elasticsearch.Password)
}
outputs.EnabledOutputs = append(outputs.EnabledOutputs, "Elasticsearch")
}
} |
I'm not sure that will work. The reason that the old system worked (and didn't leak memory) is that every time there was a |
Ok I see, your fix seems the simplest way to do so and without changing too much things |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: distortedsignal, Issif The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
LGTM label has been added. Git tree hash: 88e69613d493c0d06ec0a2a78b70db22c959402b
|
Signed-off-by: Tom Kelley [email protected]
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area outputs
What this PR does / why we need it:
Somebody made a PR that contained a memory leak for most of the outputs in the Falcosidekick. Since the header list was never reset and the output objects are long-lived (they're not recreated for each POST), headers would populate across request boundaries. For most outputs, this would be a major problem. For the
Kubeless
output, this is a critical problem since an event-id is generated for each event/POST request.Which issue(s) this PR fixes:
N/A
Special notes for your reviewer:
I'm sorry that this happened, and I'll try not to let it happen again.