Skip to content

Commit

Permalink
Increase the timeout on apiserver requests to fetch node stats.
Browse files Browse the repository at this point in the history
  • Loading branch information
vishh committed Feb 23, 2015
1 parent e186582 commit e114718
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions test/e2e/cadvisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import (
. "github.com/onsi/ginkgo"
)

const (
timeout = 1 * time.Minute
maxRetries = 10
sleepDuration = time.Minute
)

var _ = Describe("Cadvisor", func() {
var c *client.Client

Expand All @@ -44,21 +50,27 @@ func CheckCadvisorHealthOnAllNodes(c *client.Client, timeout time.Duration) {
nodeList, err := c.Nodes().List()
expectNoError(err)
var errors []error
for start := time.Now(); time.Since(start) < timeout; time.Sleep(5 * time.Second) {
retries := maxRetries
for {
errors = []error{}
for _, node := range nodeList.Items {
// cadvisor is not accessible directly unless its port (4194 by default) is exposed.
// Here, we access '/stats/' REST endpoint on the kubelet which polls cadvisor internally.
statsResource := fmt.Sprintf("api/v1beta1/proxy/minions/%s/stats/", node.Name)
By(fmt.Sprintf("Querying stats from node %s using url %s", node.Name, statsResource))
_, err = c.Get().AbsPath(statsResource).Timeout(1 * time.Second).Do().Raw()
_, err = c.Get().AbsPath(statsResource).Timeout(timeout).Do().Raw()
if err != nil {
errors = append(errors, err)
}
}
if len(errors) == 0 {
return
}
if retries--; retries <= 0 {
break
}
Logf("failed to retrieve kubelet stats -\n %v", errors)
time.Sleep(sleepDuration)
}
Failf("Timed out after %v waiting for cadvisor to be healthy on all nodes. Errors:\n%v", timeout, errors)
Failf("Failed after retrying %d times for cadvisor to be healthy on all nodes. Errors:\n%v", maxRetries, errors)
}

0 comments on commit e114718

Please sign in to comment.