mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-13 14:57:40 -08:00
Merge pull request #1665 from prometheus/fabxc-retrpanic
Fix kubernetes SD crash
This commit is contained in:
commit
74c448386c
|
@ -288,6 +288,9 @@ func (ts *targetSet) runProviders(ctx context.Context, providers map[string]Targ
|
||||||
}
|
}
|
||||||
// First set of all targets the provider knows.
|
// First set of all targets the provider knows.
|
||||||
for _, tgroup := range initial {
|
for _, tgroup := range initial {
|
||||||
|
if tgroup == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
targets, err := targetsFromGroup(tgroup, ts.config)
|
targets, err := targetsFromGroup(tgroup, ts.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With("target_group", tgroup).Errorf("Target update failed: %s", err)
|
log.With("target_group", tgroup).Errorf("Target update failed: %s", err)
|
||||||
|
@ -333,6 +336,9 @@ func (ts *targetSet) runProviders(ctx context.Context, providers map[string]Targ
|
||||||
|
|
||||||
// update handles a target group update from a target provider identified by the name.
|
// update handles a target group update from a target provider identified by the name.
|
||||||
func (ts *targetSet) update(name string, tgroup *config.TargetGroup) error {
|
func (ts *targetSet) update(name string, tgroup *config.TargetGroup) error {
|
||||||
|
if tgroup == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
targets, err := targetsFromGroup(tgroup, ts.config)
|
targets, err := targetsFromGroup(tgroup, ts.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -404,6 +410,7 @@ func providersFromConfig(cfg *config.ScrapeConfig) map[string]TargetProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
// targetsFromGroup builds targets based on the given TargetGroup and config.
|
// targetsFromGroup builds targets based on the given TargetGroup and config.
|
||||||
|
// Panics if target group is nil.
|
||||||
func targetsFromGroup(tg *config.TargetGroup, cfg *config.ScrapeConfig) ([]*Target, error) {
|
func targetsFromGroup(tg *config.TargetGroup, cfg *config.ScrapeConfig) ([]*Target, error) {
|
||||||
targets := make([]*Target, 0, len(tg.Targets))
|
targets := make([]*Target, 0, len(tg.Targets))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue