Merge pull request #27041 from wojtek-t/unschedulable_nodes

Automatic merge from submit-queue

Extend logging for UnschedulableNodes

Ref #25845
This commit is contained in:
k8s-merge-robot 2016-06-08 14:25:32 -07:00
commit e79f046990

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. // Wait till the passFunc confirms that the object it expects to see is in the store.
// Used to observe reflected events. // Used to observe reflected events.
func waitForReflection(s cache.Store, key string, passFunc func(n interface{}) bool) error { func waitForReflection(t *testing.T, s cache.Store, key string, passFunc func(n interface{}) bool) error {
return wait.Poll(time.Millisecond*10, time.Second*20, func() (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) { if n, _, err := s.GetByKey(key); err == nil && passFunc(n) {
return true, nil 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) { 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 { if _, err := c.Nodes().Update(n); err != nil {
t.Fatalf("Failed to update node with unschedulable=true: %v", err) 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 // An unschedulable node should get deleted from the store
return node == nil return node == nil
}) })
@ -172,7 +182,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore
if _, err := c.Nodes().Update(n); err != nil { if _, err := c.Nodes().Update(n); err != nil {
t.Fatalf("Failed to update node with unschedulable=false: %v", err) 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 return node != nil && node.(*api.Node).Spec.Unschedulable == false
}) })
if err != nil { if err != nil {
@ -192,7 +202,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore
if _, err = c.Nodes().UpdateStatus(n); err != nil { if _, err = c.Nodes().UpdateStatus(n); err != nil {
t.Fatalf("Failed to update node with bad status condition: %v", err) 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 return node != nil && node.(*api.Node).Status.Conditions[0].Status == api.ConditionUnknown
}) })
if err != nil { if err != nil {
@ -209,7 +219,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore
if _, err = c.Nodes().UpdateStatus(n); err != nil { if _, err = c.Nodes().UpdateStatus(n); err != nil {
t.Fatalf("Failed to update node with healthy status condition: %v", err) 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 return node != nil && node.(*api.Node).Status.Conditions[0].Status == api.ConditionTrue
}) })
if err != nil { if err != nil {