Merge pull request #27041 from wojtek-t/unschedulable_nodes

Automatic merge from submit-queue

Extend logging for UnschedulableNodes

Ref #25845
pull/6/head
k8s-merge-robot 2016-06-08 14:25:32 -07:00
commit e79f046990
1 changed files with 17 additions and 7 deletions

View File

@ -103,13 +103,23 @@ func podScheduled(c *client.Client, podNamespace, podName string) wait.Condition
// Wait till the passFunc confirms that the object it expects to see is in the store.
// Used to observe reflected events.
func waitForReflection(s cache.Store, key string, passFunc func(n interface{}) bool) error {
return wait.Poll(time.Millisecond*10, time.Second*20, func() (bool, error) {
func waitForReflection(t *testing.T, s cache.Store, key string, passFunc func(n interface{}) bool) error {
nodes := []*api.Node{}
err := wait.Poll(time.Millisecond*100, wait.ForeverTestTimeout, func() (bool, error) {
if n, _, err := s.GetByKey(key); err == nil && passFunc(n) {
return true, nil
} else {
nodes = append(nodes, n.(*api.Node))
return false, nil
}
return false, nil
})
if err != nil {
t.Logf("Logging consecutive node versions received from store:")
for i, n := range nodes {
t.Logf("%d: %#v", i, n)
}
}
return err
}
func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore cache.Store) {
@ -159,7 +169,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore
if _, err := c.Nodes().Update(n); err != nil {
t.Fatalf("Failed to update node with unschedulable=true: %v", err)
}
err = waitForReflection(s, nodeKey, func(node interface{}) bool {
err = waitForReflection(t, s, nodeKey, func(node interface{}) bool {
// An unschedulable node should get deleted from the store
return node == nil
})
@ -172,7 +182,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore
if _, err := c.Nodes().Update(n); err != nil {
t.Fatalf("Failed to update node with unschedulable=false: %v", err)
}
err = waitForReflection(s, nodeKey, func(node interface{}) bool {
err = waitForReflection(t, s, nodeKey, func(node interface{}) bool {
return node != nil && node.(*api.Node).Spec.Unschedulable == false
})
if err != nil {
@ -192,7 +202,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore
if _, err = c.Nodes().UpdateStatus(n); err != nil {
t.Fatalf("Failed to update node with bad status condition: %v", err)
}
err = waitForReflection(s, nodeKey, func(node interface{}) bool {
err = waitForReflection(t, s, nodeKey, func(node interface{}) bool {
return node != nil && node.(*api.Node).Status.Conditions[0].Status == api.ConditionUnknown
})
if err != nil {
@ -209,7 +219,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore
if _, err = c.Nodes().UpdateStatus(n); err != nil {
t.Fatalf("Failed to update node with healthy status condition: %v", err)
}
waitForReflection(s, nodeKey, func(node interface{}) bool {
err = waitForReflection(t, s, nodeKey, func(node interface{}) bool {
return node != nil && node.(*api.Node).Status.Conditions[0].Status == api.ConditionTrue
})
if err != nil {