Skip to content

Commit

Permalink
Revert "Improve push squashing" (istio#6677)
Browse files Browse the repository at this point in the history
* Revert "Remove v2 transition commands since everything is now v2 (istio#6665)"

This reverts commit 6339eb6.

* Revert "Pilot param clusterRegistriesNamespace should default to pilot namespace (istio#6446)"

This reverts commit b9294f7.

* Revert "iptable just "return" by uid as the parameter u indicates (istio#6561)"

This reverts commit 22a0b88.

* Revert "Remove node agent service, residue from flexvolume driver. (istio#6651)"

This reverts commit db3da82.

* Revert "Continuously reapply galley CA bundle to prevent overwrite (istio#6599)"

This reverts commit f9e8fd8.

* Revert "Do not count typeConfigs if it is error. (istio#6527)"

This reverts commit eb1de31.

* Revert "Make racetest green - Fixed data races and flakiness (istio#6625)"

This reverts commit 30b8ecb.

* Revert "Improve push squashing (istio#6641)"

This reverts commit 399cd2d.
  • Loading branch information
hklai authored Jun 27, 2018
1 parent 6339eb6 commit a90f565
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 47 deletions.
2 changes: 1 addition & 1 deletion install/kubernetes/helm/istio/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ sidecarInjectorWebhook:
# galley configuration
#
galley:
enabled: false
enabled: true
replicaCount: 1
image: galley
resources: {}
Expand Down
65 changes: 19 additions & 46 deletions pilot/pkg/proxy/envoy/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,10 @@ var (

var (
// Variables associated with clear cache squashing.

// lastClearCache is the time we last pushed
lastClearCache time.Time

// lastClearCacheEvent is the time of the last config event
lastClearCacheEvent time.Time

// clearCacheTimerSet is true if we are in squash mode, and a timer is already set
lastClearCache time.Time
clearCacheTimerSet bool

clearCacheMutex sync.Mutex

// clearCacheTime is the max time to squash a series of events.
// The push will happen 1 sec after the last config change, or after 'clearCacheTime'
clearCacheTime = 1
clearCacheMutex sync.Mutex
clearCacheTime = 1

// V2ClearCache is a function to be called when the v1 cache is cleared. This is used to
// avoid adding a circular dependency from v1 to v2.
Expand Down Expand Up @@ -370,6 +359,7 @@ func NewDiscoveryService(ctl model.Controller, configCache model.ConfigStoreCach
}

if configCache != nil {
// FIXME: shouldn't listen to v1alpha3
// TODO: changes should not trigger a full recompute of LDS/RDS/CDS/EDS
// (especially mixerclient HTTP and quota)
configHandler := func(model.Config, model.Event) { out.clearCache() }
Expand Down Expand Up @@ -442,40 +432,23 @@ func (ds *DiscoveryService) clearCache() {
clearCacheMutex.Lock()
defer clearCacheMutex.Unlock()

// If last config change was > 1 second ago, push.
if time.Since(lastClearCacheEvent) > 1*time.Second {
lastClearCacheEvent = time.Now()
lastClearCache = time.Now()
log.Infof("Cleared discovery service cache after 1 sec of quiet")
V2ClearCache()
return
}

lastClearCacheEvent = time.Now()

// If last config change was < 1 second ago, but last push is > clearCacheTime ago -
// also push

if time.Since(lastClearCache) > time.Duration(clearCacheTime)*time.Second {
log.Infof("Cleared discovery service cache after %v", time.Since(lastClearCache))
lastClearCache = time.Now()
V2ClearCache()
if time.Since(lastClearCache) < time.Duration(clearCacheTime)*time.Second {
if !clearCacheTimerSet {
clearCacheTimerSet = true
time.AfterFunc(time.Duration(clearCacheTime)*time.Second, func() {
clearCacheMutex.Lock()
clearCacheTimerSet = false
clearCacheMutex.Unlock()
ds.clearCache() // it's after time - so will clear the cache
})
}
return
}

// Last config change was < 1 second ago, and we're continuing to get changes.
// Set a timer 1 second in the future, to evaluate again.
// if a timer was already set, don't bother.
if !clearCacheTimerSet {
clearCacheTimerSet = true
time.AfterFunc(1*time.Second, func() {
clearCacheMutex.Lock()
clearCacheTimerSet = false
clearCacheMutex.Unlock()
ds.clearCache() // re-evaluate after 1 second. If no activity - push will happen
})
}

// TODO: clear the RDS few seconds after CDS !!
lastClearCache = time.Now()
log.Infof("Cleared discovery service cache")
ds.sdsCache.clear()
V2ClearCache()
}

// ListAllEndpoints responds with all Services and is not restricted to a single service-key
Expand Down

0 comments on commit a90f565

Please sign in to comment.