-
Notifications
You must be signed in to change notification settings - Fork 618
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
Support buffer limit option in FireLens #2958
Conversation
agent/engine/docker_task_engine.go
Outdated
@@ -1285,6 +1286,7 @@ func getFirelensLogConfig(task *apitask.Task, container *apicontainer.Container, | |||
logConfig.Config[logDriverFluentdAddress] = fluentd | |||
logConfig.Config[logDriverAsyncConnect] = strconv.FormatBool(true) | |||
logConfig.Config[logDriverSubSecondPrecision] = strconv.FormatBool(true) | |||
logConfig.Config[logDriverBufferLimit] = apitask.LogDriverBufferLimit |
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'm confused, this suggested its a field on the task structure, but then in the other file I don't see it added as a field in that struct...
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 learnt from this PR that just adding one field here is enough: https://github.com/aws/amazon-ecs-agent/pull/2538/files#diff-0f6cc891620e98230e92868ea887af5e1f11d9e692fc8415a50c1dd0b130cc8cR1106
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.
It is not a field on the task structure, it is a field in Config. And we need to get the value from the task package
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.
Okay, but our requirement is that each container can have its own log driver buffer setting. So I think it needs to be stored somewhere which is both per-task and per-container. Not some global setting.
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 don't think this needs to be saved anywhere. instead just do the following should work: (1) in collectFirelensLogOptions, skip adding the option to containerToLogOptions if the key equals firelensLogDriverBufferLimitOption; (2) here, get the actual value for "fluentd-buffer-limit" from the container's log config before we reset it at the previous line logConfig.Config = make(map[string]string)
, and then save it to the config here.
@PettitWesley @fenxiong updated the code and already tested it in my local by |
agent/engine/docker_task_engine.go
Outdated
logConfig.Type = logDriverTypeFluentd | ||
logConfig.Config = make(map[string]string) | ||
logConfig.Config[logDriverTag] = tag | ||
logConfig.Config[logDriverFluentdAddress] = fluentd | ||
logConfig.Config[logDriverAsyncConnect] = strconv.FormatBool(true) | ||
logConfig.Config[logDriverSubSecondPrecision] = strconv.FormatBool(true) | ||
logConfig.Config[logDriverBufferLimit] = bufferLimit |
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.
this should only be added when bufferLimit is not empty
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 see here has a check for empty string so I didn't add it: https://github.com/moby/moby/blob/master/daemon/logger/fluentd/fluentd.go#L174. But yeah, we should handle this case here. Thanks for the suggestion.
7da6f38
to
218c18d
Compare
Update the PR based on the comments. Will squash all commits into one if PR is approved |
static check is failing for other reason and has been fixed in 997c975. please rebase on latest dev branch to get the tests passed |
218c18d
to
7a79689
Compare
Summary
Provide an entry to configurefluentd-buffer-limit in FireLens.
This is being enabled to resolve the following request: aws/containers-roadmap#964
Implementation details
Help to configure buffer limit size in fluentD Log Driver
Testing
make test
Here is my task definition file:
Result for
docker inspect
:Also, tested it with no
log-driver-buffer-limit
option:Description for the changelog
Feature FluentD: Support for buffer limit size configuration.
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.