Skip to content

Commit 5d57f47

Browse files
committed
skip invalid IPs on pod_ips metric
1 parent f6be9ed commit 5d57f47

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

go.mod

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,9 @@ require (
8181
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
8282
gopkg.in/inf.v0 v0.9.1 // indirect
8383
gopkg.in/yaml.v2 v2.4.0 // indirect
84-
<<<<<<< HEAD
8584
gopkg.in/yaml.v3 v3.0.0 // indirect
8685
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
87-
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
8886
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
89-
||||||| parent of 2b4874e5 (Add kube_pod_ips gauge to pod metrics)
90-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
91-
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
92-
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
93-
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
94-
=======
95-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
96-
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
97-
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
98-
>>>>>>> 2b4874e5 (Add kube_pod_ips gauge to pod metrics)
9987
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
10088
sigs.k8s.io/yaml v1.3.0 // indirect
10189
)

internal/store/pod.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,13 @@ func createPodIPFamilyGenerator() generator.FamilyGenerator {
596596
for i, ip := range p.Status.PodIPs {
597597
netIP := net.ParseIPSloppy(ip.IP)
598598
var ipFamily net.IPFamily
599-
if net.IsIPv4(netIP) {
599+
switch {
600+
case net.IsIPv4(netIP):
600601
ipFamily = net.IPv4
601-
} else {
602+
case net.IsIPv6(netIP):
602603
ipFamily = net.IPv6
604+
default:
605+
continue // nil from ParseIPSloppy indicates failure to parse, so we don't include that in our metrics series
603606
}
604607
ms[i] = &metric.Metric{
605608
LabelKeys: labelKeys,

0 commit comments

Comments
 (0)