Merge pull request #72629 from krzysztof-jastrzebski/hpa_fix

Update comments in Horizontal Pod Autoscaler Controller.
This commit is contained in:
Kubernetes Prow Robot 2019-01-15 23:26:19 -08:00 committed by GitHub
commit 922cf406c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -179,7 +179,9 @@ func (a *HorizontalController) enqueueHPA(obj interface{}) {
return return
} }
// always add rate-limited so we don't fetch metrics more that once per resync interval // Requests are always added to queue with resyncPeriod delay. If there's already
// request for the HPA in the queue then a new request is always dropped. Requests spend resync
// interval in queue so HPAs are processed every resync interval.
a.queue.AddRateLimited(key) a.queue.AddRateLimited(key)
} }
@ -211,10 +213,15 @@ func (a *HorizontalController) processNextWorkItem() bool {
if err != nil { if err != nil {
utilruntime.HandleError(err) utilruntime.HandleError(err)
} }
// Add request processing HPA after resync interval just in case last resync didn't insert // Add request processing HPA to queue with resyncPeriod delay.
// request into the queue. Request is not inserted into queue by resync if previous one wasn't processed yet. // Requests are always added to queue with resyncPeriod delay. If there's already request
// This happens quite often because requests from previous resync are removed from the queue at the same moment // for the HPA in the queue then a new request is always dropped. Requests spend resyncPeriod
// as next resync inserts new requests. // in queue so HPAs are processed every resyncPeriod.
// Request is added here just in case last resync didn't insert request into the queue. This
// happens quite often because there is race condition between adding request after resyncPeriod
// and removing them from queue. Request can be added by resync before previous request is
// removed from queue. If we didn't add request here then in this case one request would be dropped
// and HPA would processed after 2 x resyncPeriod.
if !deleted { if !deleted {
a.queue.AddRateLimited(key) a.queue.AddRateLimited(key)
} }