Make replication controller synchronizations independent.
This commit is contained in:
parent
cb28f25b1b
commit
ae0baf3fab
@ -19,6 +19,7 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
@ -203,10 +204,16 @@ func (rm *ReplicationManager) synchronize() {
|
|||||||
glog.Errorf("Synchronization error: %v (%#v)", err, err)
|
glog.Errorf("Synchronization error: %v (%#v)", err, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, controllerSpec := range controllerSpecs {
|
wg := sync.WaitGroup{}
|
||||||
err = rm.syncHandler(controllerSpec)
|
wg.Add(len(controllerSpecs))
|
||||||
if err != nil {
|
for ix := range controllerSpecs {
|
||||||
glog.Errorf("Error synchronizing: %#v", err)
|
go func(ix int) {
|
||||||
}
|
defer wg.Done()
|
||||||
|
err := rm.syncHandler(controllerSpecs[ix])
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("Error synchronizing: %#v", err)
|
||||||
|
}
|
||||||
|
}(ix)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -41,13 +42,18 @@ func makeURL(suffix string) string {
|
|||||||
type FakePodControl struct {
|
type FakePodControl struct {
|
||||||
controllerSpec []api.ReplicationController
|
controllerSpec []api.ReplicationController
|
||||||
deletePodID []string
|
deletePodID []string
|
||||||
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakePodControl) createReplica(spec api.ReplicationController) {
|
func (f *FakePodControl) createReplica(spec api.ReplicationController) {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
f.controllerSpec = append(f.controllerSpec, spec)
|
f.controllerSpec = append(f.controllerSpec, spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakePodControl) deletePod(podID string) error {
|
func (f *FakePodControl) deletePod(podID string) error {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
f.deletePodID = append(f.deletePodID, podID)
|
f.deletePodID = append(f.deletePodID, podID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user