Fix spreading in resource usage gatherer

This commit is contained in:
gmarek 2016-02-25 11:54:34 +01:00
parent 82b0f0ff5e
commit ff6b3d1fb1

View File

@ -35,6 +35,7 @@ import (
const ( const (
resourceDataGatheringPeriod = 60 * time.Second resourceDataGatheringPeriod = 60 * time.Second
probeDuration = 15 * time.Second
) )
type resourceConstraint struct { type resourceConstraint struct {
@ -137,7 +138,7 @@ type resourceGatherWorker struct {
func (w *resourceGatherWorker) singleProbe() { func (w *resourceGatherWorker) singleProbe() {
data := make(resourceUsagePerContainer) data := make(resourceUsagePerContainer)
nodeUsage, err := getOneTimeResourceUsageOnNode(w.c, w.nodeName, 15*time.Second, func() []string { return w.containerIDs }, true) nodeUsage, err := getOneTimeResourceUsageOnNode(w.c, w.nodeName, probeDuration, func() []string { return w.containerIDs }, true)
if err != nil { if err != nil {
Logf("Error while reading data from %v: %v", w.nodeName, err) Logf("Error while reading data from %v: %v", w.nodeName, err)
return return
@ -168,9 +169,11 @@ func (w *resourceGatherWorker) gather(initialSleep time.Duration) {
} }
func (g *containerResourceGatherer) getKubeSystemContainersResourceUsage(c *client.Client) { func (g *containerResourceGatherer) getKubeSystemContainersResourceUsage(c *client.Client) {
delay := resourceDataGatheringPeriod / time.Duration(len(g.workers)) delayPeriod := resourceDataGatheringPeriod / time.Duration(len(g.workers))
delay := time.Duration(0)
for i := range g.workers { for i := range g.workers {
go g.workers[i].gather(delay) go g.workers[i].gather(delay)
delay += delayPeriod
} }
g.workerWg.Wait() g.workerWg.Wait()
} }