mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-06 14:17:12 +02:00
refactor[discovery, tsdb]: simplify error handling and remove redundant checks (#16328)
* refactor: simplify error handling and remove redundant checks Signed-off-by: Ryan Wu <rongjun0821@gmail.com> * Add the comment for return of reloading blocks failure Co-authored-by: Ayoub Mrini <ayoubmrini424@gmail.com> Signed-off-by: Ryan Wu <rongjun0821@gmail.com> * Add the comment for return of reloading blocks failure Signed-off-by: Ryan Wu <rongjun0821@gmail.com> --------- Signed-off-by: Ryan Wu <rongjun0821@gmail.com> Co-authored-by: Ayoub Mrini <ayoubmrini424@gmail.com>
This commit is contained in:
parent
4e91f13db2
commit
7d73c1d3f8
@ -189,9 +189,5 @@ func (i *LoadBalancerDiscovery) refresh(ctx context.Context) ([]*targetgroup.Gro
|
|||||||
tg.Targets = append(tg.Targets, labels)
|
tg.Targets = append(tg.Targets, labels)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return []*targetgroup.Group{tg}, nil
|
return []*targetgroup.Group{tg}, nil
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ package vultr
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -137,10 +136,6 @@ func NewDiscovery(conf *SDConfig, logger *slog.Logger, metrics discovery.Discove
|
|||||||
|
|
||||||
d.client.SetUserAgent(version.PrometheusUserAgent())
|
d.client.SetUserAgent(version.PrometheusUserAgent())
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("error setting up vultr agent: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
d.Discovery = refresh.NewDiscovery(
|
d.Discovery = refresh.NewDiscovery(
|
||||||
refresh.Options{
|
refresh.Options{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
|
@ -2280,10 +2280,9 @@ func (db *DB) CleanTombstones() (err error) {
|
|||||||
db.logger.Error("failed to delete block after failed `CleanTombstones`", "dir", dir, "err", err)
|
db.logger.Error("failed to delete block after failed `CleanTombstones`", "dir", dir, "err", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("reload blocks: %w", err)
|
// This should only be reached if an error occurred.
|
||||||
}
|
return fmt.Errorf("reload blocks: %w", err)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -9104,7 +9104,7 @@ func compareSeries(t require.TestingT, expected, actual map[string][]chunks.Samp
|
|||||||
require.Equal(t, eS.F(), aS.F(), "sample %d in series %q differs", i, key)
|
require.Equal(t, eS.F(), aS.F(), "sample %d in series %q differs", i, key)
|
||||||
case chunkenc.ValHistogram:
|
case chunkenc.ValHistogram:
|
||||||
eH, aH := eS.H(), aS.H()
|
eH, aH := eS.H(), aS.H()
|
||||||
if aH.CounterResetHint == histogram.UnknownCounterReset && aH.CounterResetHint != histogram.GaugeType {
|
if aH.CounterResetHint == histogram.UnknownCounterReset {
|
||||||
eH = eH.Copy()
|
eH = eH.Copy()
|
||||||
// It is always safe to set the counter reset hint to UnknownCounterReset
|
// It is always safe to set the counter reset hint to UnknownCounterReset
|
||||||
eH.CounterResetHint = histogram.UnknownCounterReset
|
eH.CounterResetHint = histogram.UnknownCounterReset
|
||||||
@ -9114,7 +9114,7 @@ func compareSeries(t require.TestingT, expected, actual map[string][]chunks.Samp
|
|||||||
|
|
||||||
case chunkenc.ValFloatHistogram:
|
case chunkenc.ValFloatHistogram:
|
||||||
eFH, aFH := eS.FH(), aS.FH()
|
eFH, aFH := eS.FH(), aS.FH()
|
||||||
if aFH.CounterResetHint == histogram.UnknownCounterReset && aFH.CounterResetHint != histogram.GaugeType {
|
if aFH.CounterResetHint == histogram.UnknownCounterReset {
|
||||||
eFH = eFH.Copy()
|
eFH = eFH.Copy()
|
||||||
// It is always safe to set the counter reset hint to UnknownCounterReset
|
// It is always safe to set the counter reset hint to UnknownCounterReset
|
||||||
eFH.CounterResetHint = histogram.UnknownCounterReset
|
eFH.CounterResetHint = histogram.UnknownCounterReset
|
||||||
|
Loading…
Reference in New Issue
Block a user