[REV] make resyncPeriod a configurable parameter

This commit is contained in:
GLYASAI 2019-01-03 18:46:45 +08:00
parent 26fdf75853
commit a49c89b157
2 changed files with 8 additions and 8 deletions

View File

@ -57,6 +57,7 @@ type Config struct {
KeepaliveRequests int
NginxUser string
IP string
ResyncPeriod time.Duration
// health check
HealthPath string
HealthCheckTimeout time.Duration
@ -99,7 +100,8 @@ func (g *GWServer) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&g.NginxUser, "nginx-user", "root", "nginx user name")
fs.IntVar(&g.KeepaliveRequests, "keepalive-requests", 10000, "Number of requests a client can make over the keep-alive connection. ")
fs.IntVar(&g.KeepaliveTimeout, "keepalive-timeout", 30, "Timeout for keep-alive connections. Server will close connections after this time.")
fs.StringVar(&g.IP, "ip", "0.0.0.0", "Node ip.") // TODO: more detail
fs.StringVar(&g.IP, "ip", "0.0.0.0", "Node ip.") // TODO: more detail
fs.DurationVar(&g.ResyncPeriod, "resync-period", 10, "the default resync period for any handlers added via AddEventHandler and how frequently the listener wants a full resync from the shared informer")
// etcd
fs.StringSliceVar(&g.EtcdEndpoint, "etcd-endpoints", []string{"http://127.0.0.1:2379"}, "etcd cluster endpoints.")
fs.IntVar(&g.EtcdTimeout, "etcd-timeout", 5, "etcd http timeout seconds")

View File

@ -22,14 +22,12 @@ import (
"bytes"
"fmt"
"github.com/goodrain/rainbond/gateway/annotations/l4"
"github.com/goodrain/rainbond/gateway/util"
"io/ioutil"
"net"
"os"
"reflect"
"strings"
"time"
"github.com/goodrain/rainbond/gateway/util"
"github.com/Sirupsen/logrus"
"github.com/eapache/channels"
@ -142,7 +140,7 @@ func New(client kubernetes.Interface,
store.listers.IngressAnnotation.Store = cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc)
// create informers factory, enable and assign required informers
infFactory := informers.NewFilteredSharedInformerFactory(client, time.Second, corev1.NamespaceAll,
infFactory := informers.NewFilteredSharedInformerFactory(client, conf.ResyncPeriod, corev1.NamespaceAll,
func(options *metav1.ListOptions) {
options.LabelSelector = "creater=Rainbond"
})
@ -317,9 +315,9 @@ func New(client kubernetes.Interface,
},
}
store.informers.Ingress.AddEventHandlerWithResyncPeriod(ingEventHandler, 10*time.Second)
store.informers.Secret.AddEventHandlerWithResyncPeriod(secEventHandler, 10*time.Second)
store.informers.Endpoint.AddEventHandlerWithResyncPeriod(epEventHandler, 10*time.Second)
store.informers.Ingress.AddEventHandler(ingEventHandler)
store.informers.Secret.AddEventHandler(secEventHandler)
store.informers.Endpoint.AddEventHandler(epEventHandler)
store.informers.Service.AddEventHandler(cache.ResourceEventHandlerFuncs{})
return store