Commit 14d0dbd2 authored by Daniel Smith's avatar Daniel Smith

Merge pull request #2239 from ddysher/node-creation-health

Return success when registrying unhealthy node.
parents ec246adb 38abf0c7
......@@ -61,7 +61,11 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
if err != nil {
return nil, err
}
minion, err := rs.registry.GetMinion(ctx, minion.Name)
minionName := minion.Name
minion, err := rs.registry.GetMinion(ctx, minionName)
if err == ErrNotHealty {
return rs.toApiMinion(minionName), nil
}
if minion == nil {
return nil, ErrDoesNotExist
}
......
......@@ -83,6 +83,29 @@ func TestMinionREST(t *testing.T) {
}
}
func TestMinionRESTWithHealthCheck(t *testing.T) {
minionRegistry := registrytest.NewMinionRegistry([]string{}, api.NodeResources{})
minionHealthRegistry := HealthyRegistry{
delegate: minionRegistry,
client: &notMinion{minion: "m1"},
}
ms := NewREST(&minionHealthRegistry)
ctx := api.NewContext()
c, err := ms.Create(ctx, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m1"}})
if err != nil {
t.Errorf("insert failed")
}
result := <-c
if m, ok := result.Object.(*api.Minion); !ok || m.Name != "m1" {
t.Errorf("insert return value was weird: %#v", result)
}
if _, err := ms.Get(ctx, "m1"); err == nil {
t.Errorf("node is unhealthy, expect no result from apiserver")
}
}
func contains(nodes *api.MinionList, nodeID string) bool {
for _, node := range nodes.Items {
if node.Name == nodeID {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment