mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 14:27:27 -08:00
Initial local pods before using the pod list to initialize pod targets; include more logging in pod target creation
This commit is contained in:
parent
e3ec8fa83b
commit
1e6770cdc5
|
@ -143,6 +143,16 @@ func (kd *Discovery) Run(ctx context.Context, ch chan<- []*config.TargetGroup) {
|
||||||
|
|
||||||
all = append(all, kd.updateAPIServersTargetGroup())
|
all = append(all, kd.updateAPIServersTargetGroup())
|
||||||
all = append(all, kd.updateNodesTargetGroup())
|
all = append(all, kd.updateNodesTargetGroup())
|
||||||
|
|
||||||
|
pods, _, err := kd.getPods()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Cannot initialize pods collection: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
kd.podsMu.Lock()
|
||||||
|
kd.pods = pods
|
||||||
|
kd.podsMu.Unlock()
|
||||||
|
|
||||||
all = append(all, kd.updatePodsTargetGroup())
|
all = append(all, kd.updatePodsTargetGroup())
|
||||||
for _, ns := range kd.pods {
|
for _, ns := range kd.pods {
|
||||||
for _, pod := range ns {
|
for _, pod := range ns {
|
||||||
|
@ -792,11 +802,6 @@ func nodeHostIP(node *Node) (net.IP, error) {
|
||||||
return nil, fmt.Errorf("host IP unknown; known addresses: %v", addresses)
|
return nil, fmt.Errorf("host IP unknown; known addresses: %v", addresses)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////
|
|
||||||
// Here there be dragons. //
|
|
||||||
// Pod discovery code lies below. //
|
|
||||||
////////////////////////////////////
|
|
||||||
|
|
||||||
func (kd *Discovery) updatePod(pod *Pod, eventType EventType) {
|
func (kd *Discovery) updatePod(pod *Pod, eventType EventType) {
|
||||||
kd.podsMu.Lock()
|
kd.podsMu.Lock()
|
||||||
defer kd.podsMu.Unlock()
|
defer kd.podsMu.Unlock()
|
||||||
|
@ -988,6 +993,11 @@ func updatePodTargets(pod *Pod, allContainers bool) []model.LabelSet {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(targets) == 0 {
|
||||||
|
log.Debugf("no targets for pod %s", pod.ObjectMeta.Name)
|
||||||
|
}
|
||||||
|
|
||||||
return targets
|
return targets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue