Fix resync of the clusters

This commit is contained in:
Murat Kabilov
2017-06-08 11:51:48 +02:00
committed by GitHub
parent bdc2db97ac
commit e104a67260
5 changed files with 32 additions and 4 deletions
+7 -2
View File
@@ -3,6 +3,7 @@ package controller
import (
"fmt"
"sync"
"time"
"github.com/Sirupsen/logrus"
"k8s.io/client-go/kubernetes"
@@ -13,6 +14,7 @@ import (
"github.com/zalando-incubator/postgres-operator/pkg/cluster"
"github.com/zalando-incubator/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util/config"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants"
"github.com/zalando-incubator/postgres-operator/pkg/util/teams"
)
@@ -38,6 +40,8 @@ type Controller struct {
podCh chan spec.PodEvent
clusterEventQueues []*cache.FIFO
lastClusterSyncTime int64
}
func New(controllerConfig *Config, operatorConfig *config.Config) *Controller {
@@ -93,7 +97,7 @@ func (c *Controller) initController() {
c.postgresqlInformer = cache.NewSharedIndexInformer(
clusterLw,
&spec.Postgresql{},
c.opConfig.ResyncPeriod,
constants.QueueResyncPeriodTPR,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
if err := c.postgresqlInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
@@ -113,7 +117,7 @@ func (c *Controller) initController() {
c.podInformer = cache.NewSharedIndexInformer(
podLw,
&v1.Pod{},
c.opConfig.ResyncPeriodPod,
constants.QueueResyncPeriodPod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
if err := c.podInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
@@ -141,6 +145,7 @@ func (c *Controller) runInformers(stopCh <-chan struct{}) {
go c.postgresqlInformer.Run(stopCh)
go c.podInformer.Run(stopCh)
go c.podEventsDispatcher(stopCh)
go c.clusterResync(stopCh)
<-stopCh
}