mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Return success when registrying unhealthy node.
This commit is contained in:
parent
ec246adbf7
commit
38abf0c7ad
@ -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: ¬Minion{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 {
|
||||
|
Loading…
Reference in New Issue
Block a user