Prevent accidental setting of sync or timeout

This commit is contained in:
Daniel Smith
2014-08-08 13:50:04 -07:00
parent 49cded3800
commit 5dd130a350
5 changed files with 55 additions and 22 deletions

View File

@@ -87,16 +87,16 @@ func MakeReplicationManager(kubeClient client.Interface) *ReplicationManager {
// Run begins watching and syncing.
func (rm *ReplicationManager) Run(period time.Duration) {
rm.syncTime = time.Tick(period)
index := uint64(0)
go util.Forever(func() { rm.watchControllers(&index) }, period)
resourceVersion := uint64(0)
go util.Forever(func() { rm.watchControllers(&resourceVersion) }, period)
}
// index is a pointer to the resource version to use/update.
func (rm *ReplicationManager) watchControllers(index *uint64) {
// resourceVersion is a pointer to the resource version to use/update.
func (rm *ReplicationManager) watchControllers(resourceVersion *uint64) {
watching, err := rm.kubeClient.WatchReplicationControllers(
labels.Everything(),
labels.Everything(),
*index,
*resourceVersion,
)
if err != nil {
glog.Errorf("Unexpected failure to watch: %v", err)
@@ -120,7 +120,7 @@ func (rm *ReplicationManager) watchControllers(index *uint64) {
glog.Errorf("unexpected object: %#v", event.Object)
} else {
// If we get disconnected, start where we left off.
*index = rc.ResourceVersion + 1
*resourceVersion = rc.ResourceVersion + 1
rm.syncHandler(*rc)
}
}

View File

@@ -339,8 +339,8 @@ func TestWatchControllers(t *testing.T) {
return nil
}
index := uint64(0)
go manager.watchControllers(&index)
resourceVersion := uint64(0)
go manager.watchControllers(&resourceVersion)
// Test normal case
testControllerSpec.ID = "foo"