Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in resource gathering to help debugging #21313 #21685

Merged
merged 1 commit into from
Feb 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions test/e2e/resource_usage_gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
. "github.com/onsi/gomega"
"k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned"
utilruntime "k8s.io/kubernetes/pkg/util/runtime"
)

const (
Expand All @@ -44,7 +45,6 @@ type resourceConstraint struct {
type containerResourceGatherer struct {
usageTimeseries map[time.Time]resourceUsagePerContainer
stopCh chan struct{}
timer *time.Ticker
wg sync.WaitGroup
}

Expand Down Expand Up @@ -79,11 +79,12 @@ func (g *containerResourceGatherer) startGatheringData(c *client.Client, period
g.usageTimeseries = make(map[time.Time]resourceUsagePerContainer)
g.wg.Add(1)
g.stopCh = make(chan struct{})
g.timer = time.NewTicker(period)
go func() error {
defer utilruntime.HandleCrash()
defer g.wg.Done()
for {
select {
case <-g.timer.C:
case <-time.After(period):
now := time.Now()
data, err := g.getKubeSystemContainersResourceUsage(c)
if err != nil {
Expand All @@ -93,7 +94,6 @@ func (g *containerResourceGatherer) startGatheringData(c *client.Client, period
g.usageTimeseries[now] = data
case <-g.stopCh:
Logf("Stop channel is closed. Stopping gatherer.")
g.wg.Done()
return nil
}
}
Expand Down Expand Up @@ -226,6 +226,7 @@ func (g *containerResourceGatherer) getKubeSystemContainersResourceUsage(c *clie
nameToUsageMap := make(resourceUsagePerContainer, len(containerIDToNameMap))
for _, node := range nodes.Items {
go func(nodeName string) {
defer utilruntime.HandleCrash()
defer wg.Done()
nodeUsage, err := getOneTimeResourceUsageOnNode(c, nodeName, 15*time.Second, func() []string { return containerIDs }, true)
mutex.Lock()
Expand Down