mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
handle nil pointer in ec2 discovery (#4469)
This handles a nil pointer that was being accessed in EC2 discovery. Fixes: #4441 Signed-off-by: noqcks <benny@noqcks.io>
This commit is contained in:
parent
8bb6e0dd6e
commit
46fb4078a6
|
@ -263,6 +263,9 @@ func (d *Discovery) refresh() (tg *targetgroup.Group, err error) {
|
||||||
var subnets []string
|
var subnets []string
|
||||||
subnetsMap := make(map[string]struct{})
|
subnetsMap := make(map[string]struct{})
|
||||||
for _, eni := range inst.NetworkInterfaces {
|
for _, eni := range inst.NetworkInterfaces {
|
||||||
|
if eni.SubnetId == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if _, ok := subnetsMap[*eni.SubnetId]; !ok {
|
if _, ok := subnetsMap[*eni.SubnetId]; !ok {
|
||||||
subnetsMap[*eni.SubnetId] = struct{}{}
|
subnetsMap[*eni.SubnetId] = struct{}{}
|
||||||
subnets = append(subnets, *eni.SubnetId)
|
subnets = append(subnets, *eni.SubnetId)
|
||||||
|
|
Loading…
Reference in a new issue