Merge pull request #21210 from mqliang/hasSync-early

Auto commit by PR queue bot
pull/6/head
k8s-merge-robot 2016-02-20 09:54:12 -08:00
commit be9dfcaec4
5 changed files with 41 additions and 35 deletions

View File

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

View File

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

View File

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

View File

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

View File

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