Commit 38abf0c7 authored by Deyuan Deng's avatar Deyuan Deng

Return success when registrying unhealthy node.

parent ec246adb
...@@ -61,7 +61,11 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE ...@@ -61,7 +61,11 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
if err != nil { if err != nil {
return nil, err 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 { if minion == nil {
return nil, ErrDoesNotExist return nil, ErrDoesNotExist
} }
......
...@@ -83,6 +83,29 @@ func TestMinionREST(t *testing.T) { ...@@ -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 { func contains(nodes *api.MinionList, nodeID string) bool {
for _, node := range nodes.Items { for _, node := range nodes.Items {
if node.Name == nodeID { 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