beats icon indicating copy to clipboard operation
beats copied to clipboard

Infinite loop while watching for Kubernetes events

Open exekias opened this issue 8 years ago • 29 comments

Both when using add_kubernetes_metadata or kubernetes autodiscover provider, some users have reported this issue (which causes an infinite loop):

2018-03-05T08:16:36.021Z        ERROR   kubernetes/watcher.go:188       kubernetes: Watching API error EOF
2018-03-05T08:16:36.021Z        INFO    kubernetes/watcher.go:173       kubernetes: Watching API for resource events
2018-03-05T08:16:36.030Z        ERROR   kubernetes/watcher.go:188       kubernetes: Watching API error proto: wrong wireType = 6 for field ServiceAccountName
2018-03-05T08:16:36.030Z        INFO    kubernetes/watcher.go:173       kubernetes: Watching API for resource events
2018-03-05T08:16:36.031Z        ERROR   kubernetes/watcher.go:188       kubernetes: Watching API error proto: wrong wireType = 6 for field ServiceAccountName
2018-03-05T08:16:36.031Z        INFO    kubernetes/watcher.go:173       kubernetes: Watching API for resource events
2018-03-05T08:16:36.033Z        ERROR   kubernetes/watcher.go:188       kubernetes: Watching API error proto: wrong wireType = 6 for field ServiceAccountName

More details can be found here: https://github.com/elastic/beats/pull/6353

exekias avatar Mar 07 '18 02:03 exekias

I've pushed a branch ignoring unmarshall errors: https://github.com/exekias/beats/tree/ignore-k8s-errors

Also built an image from it: exekias/filebeat:ignore-k8s-errors, @simioa it would be awesome if you could do another test, your help here is much appreciated

exekias avatar Mar 07 '18 02:03 exekias

@exekias Looks good, no problems till now.

simioa avatar Mar 09 '18 08:03 simioa

Good to hear, @simioa, I'm wondering, did you see the ERROR happen?

The code doesn't really avoid that message but should recover from it in all cases: kubernetes: Watching API error proto: wrong wireType = 6 for field ServiceAccountName

exekias avatar Mar 09 '18 09:03 exekias

Not that ERROR Message but this:

2018-03-08T15:33:50.114Z        ERROR   kubernetes/watcher.go:198       kubernetes: Watching API error EOF

I just looked into an Filebeat 6.2.2 Log and saw that right after the kubernetes: Watching API error EOF ERROR appeared, the infinite loop started.

This is not the case anymore, the only thing logged after the EOF Error related to the Watching API is:

2018-03-08T15:33:50.114Z        INFO    kubernetes/watcher.go:181       kubernetes: Watching API for resource events

simioa avatar Mar 09 '18 09:03 simioa

Ok, please keep an eye on it and report if it happens :innocent:

In the meanwhile, it seems we now have a way to reproduce it, I will be doing some testing myself

Thank you for your effort! It's really helping with this issue

exekias avatar Mar 09 '18 09:03 exekias

A fix has been merged and should go out in both 6.3.0 and 6.2.3

exekias avatar Mar 12 '18 10:03 exekias

what's the ETA for new container 6.2.3 with the fix merged ?

primeroz avatar Mar 13 '18 15:03 primeroz

It should be out soon, in any case, for convenience, I've pushed a snapshot build with the fix: exekias/filebeat:6.2.3-snapshot

exekias avatar Mar 13 '18 15:03 exekias

An update on this, new images for 6.2.3 are already available: https://www.docker.elastic.co/

exekias avatar Mar 20 '18 19:03 exekias

@exekias this error also appears in 6.4.0, kubernetes 1.6.4 , any workaround for this?

2018-08-19T01:53:44.655Z	ERROR	kubernetes/watcher.go:254	kubernetes: Watching API error EOF
2018-08-19T01:53:44.655Z	INFO	kubernetes/watcher.go:238	kubernetes: Watching API for resource events
2018-08-19T01:53:53.051Z	ERROR	kubernetes/watcher.go:254	kubernetes: Watching API error EOF
2018-08-19T01:53:53.051Z	INFO	kubernetes/watcher.go:238	kubernetes: Watching API for resource events
2018-08-19T01:53:53.293Z	ERROR	kubernetes/watcher.go:254	kubernetes: Watching API error EOF
2018-08-19T01:53:53.294Z	INFO	kubernetes/watcher.go:238	kubernetes: Watching API for resource events
2018-08-19T01:53:54.065Z	ERROR	kubernetes/watcher.go:254	kubernetes: Watching API error EOF
2018-08-19T01:53:54.065Z	INFO	kubernetes/watcher.go:238	kubernetes: Watching API for resource events
2018-08-19T01:54:05.405Z	ERROR	kubernetes/watcher.go:254	kubernetes: Watching API error EOF
2018-08-19T01:54:05.405Z	INFO	kubernetes/watcher.go:238	kubernetes: Watching API for resource events
2018-08-19T01:54:07.414Z	ERROR	kubernetes/watcher.go:254	kubernetes: Watching API error EOF
2018-08-19T01:54:07.414Z	INFO	kubernetes/watcher.go:238	kubernetes: Watching API for resource events

yangyuw avatar Aug 19 '18 02:08 yangyuw

Still appears in 6.3.2:

2018-08-25T14:50:05.364Z        INFO    [beat]  instance/beat.go:725    Build info      {"system_info": {"build": {"commit": "45a9a9e1561b6c540e94211ebe03d18abcacae55", "libbeat": "6.3.2", "time": "2018-07-20T04:18:19.000Z", "version": "6.3.2"}}}
...
2018-08-25T18:40:57.180Z        ERROR   kubernetes/watcher.go:195       kubernetes: Watching API error EOF
2018-08-25T18:40:57.180Z        INFO    kubernetes/watcher.go:179       kubernetes: Watching API for resource events

hobti01 avatar Aug 26 '18 12:08 hobti01

@hobti01 Do you have memory issue with filebeat process? With the error appear more and more frequently, the memory useage may grow to 5GB and more.In my cluster, this error appears after filebeat restart about 1 hour. I found the root cause maybe this line, w.r return empty string, which is abnormal.

https://github.com/elastic/beats/blob/0b32c2d7604145eabb7b5652dc8de7bcccf64baf/vendor/github.com/ericchiang/k8s/watch.go#L100

yangyuw avatar Aug 26 '18 14:08 yangyuw

@yu-yang2 we do not have memory issues. We have noticed that sometimes log shipping will stop for an application container when we update filebeat and is not restarted.

This is the only ERROR in our logs, but this seems to be just a warning about the Kubernetes watch which is automatically restarted.

hobti01 avatar Aug 27 '18 05:08 hobti01

Same here filebeat version 6.3.2

2018-09-05T04:47:25.540Z	ERROR	kubernetes/watcher.go:195	kubernetes: Watching API error EOF
2018-09-05T04:47:25.541Z	INFO	kubernetes/watcher.go:179	kubernetes: Watching API for resource events```

agoloAbbas avatar Sep 05 '18 16:09 agoloAbbas

Same error in filebeat v6.4.2 Installed from https://github.com/helm/charts/tree/master/stable/filebeat

2018-11-09T15:03:07.979+0600	ERROR	kubernetes/watcher.go:254	kubernetes: Watching API error EOF

mslga avatar Nov 09 '18 09:11 mslga

I also got this error in v6.4.3. The pod with this error stops collecting kubernetes' metadata. When I restart the pod, the metadata collection resumes, but appears again after a few hours.

2018-11-13T12:23:44.563Z	ERROR	kubernetes/watcher.go:254	kubernetes: Watching API error EOF
2018-11-13T12:23:44.563Z	INFO	kubernetes/watcher.go:238	kubernetes: Watching API for resource events

thspinto avatar Nov 13 '18 12:11 thspinto

I also have the same errors with v6.4.3 my filebeat memory usage grows until it's killed by kubernetes at about 1gb of usage per pod.

bwunderlich824 avatar Nov 13 '18 17:11 bwunderlich824

same error for v6.4.3: 2018-11-13T21:11:43.472+0800 ERROR kubernetes/watcher.go:254 kubernetes: Watching API error EOF 2018-11-13T21:11:43.472+0800 INFO kubernetes/watcher.go:238 kubernetes: Watching API for resource events 2018-11-13T21:11:43.474+0800 ERROR kubernetes/watcher.go:254 kubernetes: Watching API error proto: illegal wireType 6 2018-11-13T21:11:43.474+0800 INFO kubernetes/watcher.go:258 kubernetes: Ignoring event, moving to most recent resource version 2018-11-13T21:11:43.474+0800 INFO kubernetes/watcher.go:238 kubernetes: Watching API for resource events

opsnull avatar Nov 14 '18 03:11 opsnull

Can we have this re-opened since the issues seems to still be occurring?

bwunderlich824 avatar Nov 14 '18 16:11 bwunderlich824

@opsnull Do you also see filebeat consuming large amounts of memory?

bwunderlich824 avatar Nov 14 '18 16:11 bwunderlich824