Change flap detection configuration (#914)

* Change flap detection configuration

* Make PenaltyHalfLife a float, not int 🤦‍♂️

* Lower event suppression to 200
This commit is contained in:
Milos Gajdos 2019-11-04 19:01:52 +00:00 committed by Asim Aslam
parent 24b8d2a315
commit 4a694c9d02

View File

@ -21,15 +21,15 @@ const (
// AdvertiseFlushTick is time the yet unconsumed advertisements are flush i.e. discarded // AdvertiseFlushTick is time the yet unconsumed advertisements are flush i.e. discarded
AdvertiseFlushTick = 15 * time.Second AdvertiseFlushTick = 15 * time.Second
// AdvertSuppress is advert suppression threshold // AdvertSuppress is advert suppression threshold
AdvertSuppress = 2000.0 AdvertSuppress = 200.0
// AdvertRecover is advert recovery threshold // AdvertRecover is advert recovery threshold
AdvertRecover = 500.0 AdvertRecover = 120.0
// DefaultAdvertTTL is default advertisement TTL // DefaultAdvertTTL is default advertisement TTL
DefaultAdvertTTL = 1 * time.Minute DefaultAdvertTTL = 1 * time.Minute
// Penalty for routes processed multiple times // Penalty for routes processed multiple times
Penalty = 2000.0 Penalty = 100.0
// PenaltyHalfLife is the time the advert penalty decays to half its value // PenaltyHalfLife is the time the advert penalty decays to half its value
PenaltyHalfLife = 2.5 PenaltyHalfLife = 30.0
// MaxSuppressTime defines time after which the suppressed advert is deleted // MaxSuppressTime defines time after which the suppressed advert is deleted
MaxSuppressTime = 5 * time.Minute MaxSuppressTime = 5 * time.Minute
) )
@ -396,21 +396,24 @@ func (r *router) advertiseEvents() error {
advert.isSuppressed = false advert.isSuppressed = false
} }
// max suppression time threshold has been reached, delete the advert
if advert.isSuppressed { if advert.isSuppressed {
// max suppression time threshold has been reached, delete the advert
if time.Since(advert.suppressTime) > MaxSuppressTime { if time.Since(advert.suppressTime) > MaxSuppressTime {
delete(advertMap, key) delete(advertMap, key)
continue continue
} }
// process next advert
continue
} }
if !advert.isSuppressed { // copy the event and append
e := new(Event) e := new(Event)
*e = *(advert.event) // this is ok, because router.Event only contains builtin types
events = append(events, e) // and no references so this creates a deep struct copy of Event
// delete the advert from the advertMap *e = *(advert.event)
delete(advertMap, key) events = append(events, e)
} // delete the advert from the advertMap
delete(advertMap, key)
} }
// advertise all Update events to subscribers // advertise all Update events to subscribers