Return immediately when controllers/pods are committed

Add client waiting conditions.
This commit is contained in:
Clayton Coleman
2014-08-18 17:42:08 -04:00
parent 34031dbc6a
commit 493863eb93
10 changed files with 311 additions and 58 deletions

View File

@@ -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
}

View File

@@ -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")
}
}