mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 05:04:05 -08:00
Dedup code handling getting network interface
Signed-off-by: Daniel Nicholls <daniel.nicholls@resdiary.com>
This commit is contained in:
parent
775de1a3bd
commit
0704c72548
|
@ -411,29 +411,19 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) {
|
||||||
} else {
|
} else {
|
||||||
if vm.ScaleSet == "" {
|
if vm.ScaleSet == "" {
|
||||||
networkInterface, err = client.getVMNetworkInterfaceByID(ctx, nicID)
|
networkInterface, err = client.getVMNetworkInterfaceByID(ctx, nicID)
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, errorNotFound) {
|
|
||||||
level.Warn(d.logger).Log("msg", "Network interface does not exist", "name", nicID, "err", err)
|
|
||||||
} else {
|
|
||||||
ch <- target{labelSet: nil, err: err}
|
|
||||||
}
|
|
||||||
// Get out of this routine because we cannot continue without a network interface.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
d.addToCache(nicID, networkInterface)
|
|
||||||
} else {
|
} else {
|
||||||
networkInterface, err = client.getVMScaleSetVMNetworkInterfaceByID(ctx, nicID, vm.ScaleSet, vm.InstanceID)
|
networkInterface, err = client.getVMScaleSetVMNetworkInterfaceByID(ctx, nicID, vm.ScaleSet, vm.InstanceID)
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, errorNotFound) {
|
|
||||||
level.Warn(d.logger).Log("msg", "Network interface does not exist", "name", nicID, "err", err)
|
|
||||||
} else {
|
|
||||||
ch <- target{labelSet: nil, err: err}
|
|
||||||
}
|
|
||||||
// Get out of this routine because we cannot continue without a network interface.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
d.addToCache(nicID, networkInterface)
|
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, errorNotFound) {
|
||||||
|
level.Warn(d.logger).Log("msg", "Network interface does not exist", "name", nicID, "err", err)
|
||||||
|
} else {
|
||||||
|
ch <- target{labelSet: nil, err: err}
|
||||||
|
}
|
||||||
|
// Get out of this routine because we cannot continue without a network interface.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
d.addToCache(nicID, networkInterface)
|
||||||
}
|
}
|
||||||
|
|
||||||
if networkInterface.Properties == nil {
|
if networkInterface.Properties == nil {
|
||||||
|
|
Loading…
Reference in a new issue