mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 21:50:05 +00:00
Return immediately when controllers/pods are committed
Add client waiting conditions.
This commit is contained in:
@@ -48,7 +48,7 @@ func NewRegistryStorage(registry Registry, podRegistry pod.Registry) apiserver.R
|
||||
}
|
||||
}
|
||||
|
||||
// Create registers then given ReplicationController.
|
||||
// Create registers the given ReplicationController.
|
||||
func (rs *RegistryStorage) Create(obj interface{}) (<-chan interface{}, error) {
|
||||
controller, ok := obj.(*api.ReplicationController)
|
||||
if !ok {
|
||||
@@ -70,7 +70,7 @@ func (rs *RegistryStorage) Create(obj interface{}) (<-chan interface{}, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rs.waitForController(*controller)
|
||||
return rs.registry.GetController(controller.ID)
|
||||
}), nil
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func (rs *RegistryStorage) Update(obj interface{}) (<-chan interface{}, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rs.waitForController(*controller)
|
||||
return rs.registry.GetController(controller.ID)
|
||||
}), nil
|
||||
}
|
||||
|
||||
|
@@ -239,30 +239,10 @@ func TestCreateController(t *testing.T) {
|
||||
}
|
||||
|
||||
select {
|
||||
case <-channel:
|
||||
// expected case
|
||||
case <-time.After(time.Millisecond * 100):
|
||||
// Do nothing, this is expected.
|
||||
case <-channel:
|
||||
t.Error("Unexpected read from async channel")
|
||||
}
|
||||
|
||||
mockPodRegistry.Lock()
|
||||
mockPodRegistry.Pods = []api.Pod{
|
||||
{
|
||||
JSONBase: api.JSONBase{ID: "foo"},
|
||||
Labels: map[string]string{"a": "b"},
|
||||
},
|
||||
{
|
||||
JSONBase: api.JSONBase{ID: "bar"},
|
||||
Labels: map[string]string{"a": "b"},
|
||||
},
|
||||
}
|
||||
mockPodRegistry.Unlock()
|
||||
|
||||
select {
|
||||
case <-time.After(time.Second * 1):
|
||||
t.Error("Unexpected timeout")
|
||||
case <-channel:
|
||||
// Do nothing, this is expected
|
||||
t.Error("Unexpected timeout from async channel")
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user