-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
in_docker: stricter config json name matching #5343
base: master
Are you sure you want to change the base?
Conversation
debug log
|
93823c3
to
01b2c76
Compare
@edsiper @patrick-stephens seems CODEOWNERS is broken on this one and did not request reviewers... |
It should have been caught by the default one so not sure why that didn't work, although maybe a Github issue. |
Ah, the configuration seems to specify a user that does not map for me at least:
So that is likely why, I'll raise a separate issue on updating that. |
I'm not familiar with docker swarm. Note: It contains
Summary: {
"NetworkSettings": {
"Service": {
"Name":"hoge"
},
},
"Name":"/hoge"
} |
thanks for the comment @nokute78 as container names always start with /, adding that to the extraction fixes it (without doing full json parsing) |
@fopina I didn't confirm that first character of container name should be In my understanding, this patch depends on the struct |
I haven’t looked it up documented, I’ll try to find it in the code itself. But even without that confirmation, I believe it’s safe to assume that, from two different perspectives:
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
I was just now going to upgrade my fork from this plugin to fluent-bit v2 and realized it was only to address this issue that is still open. Is it still up for consideration / Is it worth for me to resolve conflicts and update the PR? |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
let's fix the conflicts to revisit pls |
Has anything changed regarding @nokute78 concerns? They're not related to code itself, so I don't see why resolving the conflicts would help before clearing that up |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
…warm service name if any) Signed-off-by: Filipe Pina <[email protected]>
01b2c76
to
6b54d44
Compare
hi @edsiper giving this PR another try, let me know if it's ok now |
I'd like to re-iterate the issue here: Regarding previous questions about not seeing a slash anywhere, it's important to highlight this plugin is not using docker API, it's reading the config.v2.json file directly. This is output of a {"StreamConfig":{},"State":{"Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"RemovalInProgress":false,"Dead":false,"Pid":236,"ExitCode":0,"Error":"","StartedAt":"2024-11-02T19:56:50.661022417Z","FinishedAt":"0001-01-01T00:00:00Z","Health":null},"ID":"53ede05dffac31d9d10cae92fbc6a7b1bfa219f526cbb2db097451be3fdbcd11","Created":"2024-11-02T19:56:50.483934923Z","Managed":false,"Path":"tail","Args":["-f","/dev/null"],"Config":{"Hostname":"53ede05dffac","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["tail","-f","/dev/null"],"Image":"alpine","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":{}},"Image":"sha256:91ef0af61f39ece4d6710e465df5ed6ca12112358344fd51ae6a3b886634148b","ImageManifest":null,"NetworkSettings":{"Bridge":"","SandboxID":"404058c64e41043d97ace4d5dcb25b304976a252e016f737eaf301070db9846e","SandboxKey":"/var/run/docker/netns/404058c64e41","HairpinMode":false,"LinkLocalIPv6Address":"","LinkLocalIPv6PrefixLen":0,"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"MacAddress":"02:42:ac:12:00:02","DriverOpts":null,"NetworkID":"38d188b71dfe64dd67436dc65743636f03fbe49f459b4f82fda16c8fcbc401de","EndpointID":"133c66c22dfe48d473555669bcd108bd4a032d67198eb77f333d62332234e112","Gateway":"172.18.0.1","IPAddress":"172.18.0.2","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null,"IPAMOperational":false,"DesiredMacAddress":""}},"Service":null,"Ports":{},"SecondaryIPAddresses":null,"SecondaryIPv6Addresses":null,"HasSwarmEndpoint":false},"LogPath":"/var/lib/docker/containers/53ede05dffac31d9d10cae92fbc6a7b1bfa219f526cbb2db097451be3fdbcd11/53ede05dffac31d9d10cae92fbc6a7b1bfa219f526cbb2db097451be3fdbcd11-json.log","Name":"/vibrant_proskuriakova","Driver":"vfs","OS":"linux","RestartCount":0,"HasBeenStartedBefore":true,"HasBeenManuallyStopped":false,"MountPoints":{},"SecretReferences":null,"ConfigReferences":null,"MountLabel":"","ProcessLabel":"","AppArmorProfile":"","SeccompProfile":"","NoNewPrivileges":false,"HostnamePath":"/var/lib/docker/containers/53ede05dffac31d9d10cae92fbc6a7b1bfa219f526cbb2db097451be3fdbcd11/hostname","HostsPath":"/var/lib/docker/containers/53ede05dffac31d9d10cae92fbc6a7b1bfa219f526cbb2db097451be3fdbcd11/hosts","ShmPath":"","ResolvConfPath":"/var/lib/docker/containers/53ede05dffac31d9d10cae92fbc6a7b1bfa219f526cbb2db097451be3fdbcd11/resolv.conf","LocalLogCacheMeta":{"HaveNotifyEnabled":false}} We can see only one Now moving to a host using docker swarm, and checking a container that does belong to swarm service {
"StreamConfig": {},
"Service": {
"Name": "dojo_runnerdinda4",
},
"Name": "/dojo_runnerdinda4.1.9qdppb11pqkqlqj791zft1cyy",
} I've formatted so it's easier to read and removed everything in between: There's an entry for As it is listed before the container name, By adding |
When a container is part of a docker swarm service, service name was reported (instead of container name) and first char was lost
Currently
"name"=>"kron_agents"
:Expected
"name"=>"dkron2_agents.o2y1zv88kwvw97w14brnqneen.attv68rjfwcyg227xgpcogl1w"
:The issue is that this plugin extracts container name by looking at its config json, finding the first
"Name"
entry and skipping 9 characters, which also skips the leading/
in internal container names.The problem is that when container belongs to a swarm service there's a JSON entry
{Service: {Name: ...}
that is listed before container name and the extract code does not expect that. Result being service name is extracted instead of container name and, as service names are not prefixed with/
, the first character is lost.This change updates the extract code to look for
"Name":"/
specifically, assuming proper JSON parsing was not implemented from the start for performance reasons.It has also been done in a standalone fork of the plugin so I could test/use straight away - https://github.com/fopina/fluent-bit-in-docker2
Enter
[N/A]
in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.