diff --git a/pkg/controller/daemon/controller.go b/pkg/controller/daemon/controller.go index 5e9a590fcf..44c44f4556 100644 --- a/pkg/controller/daemon/controller.go +++ b/pkg/controller/daemon/controller.go @@ -535,6 +535,15 @@ func (dsc *DaemonSetsController) syncDaemonSet(key string) error { defer func() { glog.V(4).Infof("Finished syncing daemon set %q (%v)", key, time.Now().Sub(startTime)) }() + + if !dsc.podStoreSynced() { + // Sleep so we give the pod reflector goroutine a chance to run. + time.Sleep(PodStoreSyncedPollPeriod) + glog.Infof("Waiting for pods controller to sync, requeuing ds %v", key) + dsc.queue.Add(key) + return nil + } + obj, exists, err := dsc.dsStore.Store.GetByKey(key) if err != nil { glog.Infof("Unable to retrieve ds %v from store: %v", key, err) @@ -547,13 +556,6 @@ func (dsc *DaemonSetsController) syncDaemonSet(key string) error { return nil } ds := obj.(*extensions.DaemonSet) - if !dsc.podStoreSynced() { - // Sleep so we give the pod reflector goroutine a chance to run. - time.Sleep(PodStoreSyncedPollPeriod) - glog.Infof("Waiting for pods controller to sync, requeuing ds %v", ds.Name) - dsc.enqueueDaemonSet(ds) - return nil - } // Don't process a daemon set until all its creations and deletions have been processed. // For example if daemon set foo asked for 3 new daemon pods in the previous call to manage, diff --git a/pkg/controller/deployment/deployment_controller.go b/pkg/controller/deployment/deployment_controller.go index b4e3218d92..b1eaa67897 100644 --- a/pkg/controller/deployment/deployment_controller.go +++ b/pkg/controller/deployment/deployment_controller.go @@ -397,6 +397,14 @@ func (dc *DeploymentController) syncDeployment(key string) error { glog.V(4).Infof("Finished syncing deployment %q (%v)", key, time.Now().Sub(startTime)) }() + if !dc.rsStoreSynced() || !dc.podStoreSynced() { + // Sleep so we give the replica set / pod reflector goroutine a chance to run. + time.Sleep(StoreSyncedPollPeriod) + glog.Infof("Waiting for replica set / pod controller to sync, requeuing deployment %s", key) + dc.queue.Add(key) + return nil + } + obj, exists, err := dc.dStore.Store.GetByKey(key) if err != nil { glog.Infof("Unable to retrieve deployment %v from store: %v", key, err) @@ -410,13 +418,6 @@ func (dc *DeploymentController) syncDeployment(key string) error { return nil } d := *obj.(*extensions.Deployment) - if !dc.rsStoreSynced() || !dc.podStoreSynced() { - // Sleep so we give the replica set / pod reflector goroutine a chance to run. - time.Sleep(StoreSyncedPollPeriod) - glog.Infof("Waiting for replica set / pod controller to sync, requeuing deployment %s", d.Name) - dc.enqueueDeployment(&d) - return nil - } if d.Spec.Paused { // Ignore paused deployments diff --git a/pkg/controller/job/controller.go b/pkg/controller/job/controller.go index 38ee3a893a..b1d7a6a583 100644 --- a/pkg/controller/job/controller.go +++ b/pkg/controller/job/controller.go @@ -288,6 +288,14 @@ func (jm *JobController) syncJob(key string) error { glog.V(4).Infof("Finished syncing job %q (%v)", key, time.Now().Sub(startTime)) }() + if !jm.podStoreSynced() { + // Sleep so we give the pod reflector goroutine a chance to run. + time.Sleep(replicationcontroller.PodStoreSyncedPollPeriod) + glog.V(4).Infof("Waiting for pods controller to sync, requeuing job %v", key) + jm.queue.Add(key) + return nil + } + obj, exists, err := jm.jobStore.Store.GetByKey(key) if !exists { glog.V(4).Infof("Job has been deleted: %v", key) @@ -300,13 +308,6 @@ func (jm *JobController) syncJob(key string) error { return err } job := *obj.(*extensions.Job) - if !jm.podStoreSynced() { - // Sleep so we give the pod reflector goroutine a chance to run. - time.Sleep(replicationcontroller.PodStoreSyncedPollPeriod) - glog.V(4).Infof("Waiting for pods controller to sync, requeuing job %v", job.Name) - jm.enqueueController(&job) - return nil - } // Check the expectations of the job before counting active pods, otherwise a new pod can sneak in // and update the expectations after we've retrieved active pods from the store. If a new pod enters diff --git a/pkg/controller/replicaset/replica_set.go b/pkg/controller/replicaset/replica_set.go index cd10e429cf..eb8ec2e641 100644 --- a/pkg/controller/replicaset/replica_set.go +++ b/pkg/controller/replicaset/replica_set.go @@ -407,6 +407,14 @@ func (rsc *ReplicaSetController) syncReplicaSet(key string) error { glog.V(4).Infof("Finished syncing replica set %q (%v)", key, time.Now().Sub(startTime)) }() + if !rsc.podStoreSynced() { + // Sleep so we give the pod reflector goroutine a chance to run. + time.Sleep(PodStoreSyncedPollPeriod) + glog.Infof("Waiting for pods controller to sync, requeuing ReplicaSet %v", key) + rsc.queue.Add(key) + return nil + } + obj, exists, err := rsc.rsStore.Store.GetByKey(key) if !exists { glog.Infof("ReplicaSet has been deleted %v", key) @@ -419,13 +427,6 @@ func (rsc *ReplicaSetController) syncReplicaSet(key string) error { return err } rs := *obj.(*extensions.ReplicaSet) - if !rsc.podStoreSynced() { - // Sleep so we give the pod reflector goroutine a chance to run. - time.Sleep(PodStoreSyncedPollPeriod) - glog.Infof("Waiting for pods controller to sync, requeuing ReplicaSet %v", rs.Name) - rsc.enqueueReplicaSet(&rs) - return nil - } // Check the expectations of the ReplicaSet before counting active pods, otherwise a new pod can sneak // in and update the expectations after we've retrieved active pods from the store. If a new pod enters diff --git a/pkg/controller/replication/replication_controller.go b/pkg/controller/replication/replication_controller.go index 1e234b8cc3..9aa8cab7a3 100644 --- a/pkg/controller/replication/replication_controller.go +++ b/pkg/controller/replication/replication_controller.go @@ -409,6 +409,14 @@ func (rm *ReplicationManager) syncReplicationController(key string) error { glog.V(4).Infof("Finished syncing controller %q (%v)", key, time.Now().Sub(startTime)) }() + if !rm.podStoreSynced() { + // Sleep so we give the pod reflector goroutine a chance to run. + time.Sleep(PodStoreSyncedPollPeriod) + glog.Infof("Waiting for pods controller to sync, requeuing rc %v", key) + rm.queue.Add(key) + return nil + } + obj, exists, err := rm.rcStore.Store.GetByKey(key) if !exists { glog.Infof("Replication Controller has been deleted %v", key) @@ -421,13 +429,6 @@ func (rm *ReplicationManager) syncReplicationController(key string) error { return err } rc := *obj.(*api.ReplicationController) - if !rm.podStoreSynced() { - // Sleep so we give the pod reflector goroutine a chance to run. - time.Sleep(PodStoreSyncedPollPeriod) - glog.Infof("Waiting for pods controller to sync, requeuing rc %v", rc.Name) - rm.enqueueController(&rc) - return nil - } // Check the expectations of the rc before counting active pods, otherwise a new pod can sneak in // and update the expectations after we've retrieved active pods from the store. If a new pod enters