Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up[Kubernetes] Delete targets for evicted pods #3837
Comments
This comment has been minimized.
This comment has been minimized.
|
Related sources: https://github.com/prometheus/prometheus/blob/master/discovery/kubernetes/pod.go How it works (apparently):
I can't reproduce the issue with following patch (but it doesn't look good): diff --git a/discovery/kubernetes/pod.go b/discovery/kubernetes/pod.go
index ef8ce6d..cfe9e33 100644
--- a/discovery/kubernetes/pod.go
+++ b/discovery/kubernetes/pod.go
@@ -98,7 +98,14 @@ func (p *Pod) Run(ctx context.Context, ch chan<- []*config.TargetGroup) {
p.logger.With("err", err).Errorln("converting to Pod object failed")
return
}
- send(p.buildPod(pod))
+
+ // During eviction pod can lose their IP.
+ // In this case we should remove them from targets.
+ if len(pod.Status.PodIP) == 0 {
+ send(&config.TargetGroup{Source: podSource(pod)})
+ } else {
+ send(p.buildPod(pod))
+ }
},
})
Maybe it will be helpful. |
This comment has been minimized.
This comment has been minimized.
|
I would think that there is some sort of condition field or something in the Pod's status, that it has been evicted, that seem like a more appropriate check that the amount of IPs (maybe there are other conditions than eviction that make IP count 0? I wouldn't want to swallow those without knowing what's happening). In general I think this should be added. |
This comment has been minimized.
This comment has been minimized.
|
FWIW A change like this would make sense IMO:
|
This comment has been minimized.
This comment has been minimized.
|
Sounds reasonable @simonpasquier |
simonpasquier
referenced this issue
Feb 14, 2018
Merged
Send update when pod's IP address is empty #3842
This comment has been minimized.
This comment has been minimized.
|
I can't reproduce the issue with @simonpasquier's patch (tested with v2.2.0-rc.0) and it looks great. |
This comment has been minimized.
This comment has been minimized.
|
Interesting. Then it seems it was one of the general SD bugs that were present in v2.1.0. Sorry for the inconvenience. @simonpasquier's patch is still applicable though I think, so let's keep this open until we merge that. |
fabxc
closed this
in
#3842
Feb 19, 2018
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
Mar 22, 2019
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
seleznev commentedFeb 14, 2018
For now Prometheus tries to scrape metrics from evicted pods (that have no IP and doesn't perform in cluster). It can cause false alerts or ever scraping metrics from another pod (for ex. if you use
hostNetwork+hostPortfor your deployment and new pod will be created on same node as evicted pod).What did you do?
Steps to reproduce:
On
/targetspage you will see new target for created pod.Do something to trigger eviction pods from node (for example, change
--eviction-hardsettings for kubelet).Verify that pod is evicted with kubectl. It will looks like:
/targetspage. Target for evicted pod will be still here.What did you expect to see?
No target for evicted pod on step 5.
What did you see instead? Under which circumstances?
Evicted pod has target on
/targetspage (with down state in most cases).Environment
System information:
Linux 4.4.0-104-generic x86_64
Prometheus version:
Prometheus configuration file:
Relevant part: