All be damned.


2013/2/25 juliusv <notifications@github.com>

> In retrieval/targetpool.go:
>
> > +func (p *TargetPool) replaceTargets(newTargets []Target) {
> > +	// Replace old target list by new one, but reuse those targets from the old
> > +	// list of targets which are also in the new list (to preserve scheduling and
> > +	// health state).
> > +	for j, newTarget := range newTargets {
> > +		for _, oldTarget := range p.targets {
> > +			if oldTarget.Address() == newTarget.Address() {
> > +				oldTarget.Merge(newTargets[j])
> > +				newTargets[j] = oldTarget
> > +			}
> > +		}
> > +	}
> > +	p.targets = newTargets
> > +
> > +	// Reestablish heap invariants.
> > +	heap.Init(p)
>
> Yes, this reorders the elements in the p.targets heap array according to
> their scheduling times. The only reason why you didn't need to initially
> call Init() in the existing implementation was because you started off with
> an empty array, which by definition satisfies the heap conditions at the
> beginning (and then you only use heap operations to mutate the array). But
> since the replacement case starts off with a populated (but unordered)
> list, I need to call this in this case. This confused me too, at first.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/prometheus/prometheus/pull/86/files#r3145601>
> .
>