From ebfb3c241b3f5c08ad81d73b83b3fe06ff943f87 Mon Sep 17 00:00:00 2001 From: liang Date: Sat, 28 Apr 2018 15:50:19 +0000 Subject: [PATCH 1/2] change gossip dns conn limit by ENV --- nodeup/pkg/bootstrap/install.go | 6 ++++++ nodeup/pkg/model/protokube.go | 9 +++++++++ pkg/model/bootstrapscript.go | 5 +++++ protokube/pkg/gossip/mesh/gossip.go | 16 +++++++++++++++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/nodeup/pkg/bootstrap/install.go b/nodeup/pkg/bootstrap/install.go index 0c4279f1c9..e8cc825a4b 100644 --- a/nodeup/pkg/bootstrap/install.go +++ b/nodeup/pkg/bootstrap/install.go @@ -119,6 +119,12 @@ func (i *Installation) buildSystemdJob() *nodetasks.Service { buffer.WriteString("\" ") } + if os.Getenv("GOSSIP_DNS_CONN_LIMIT") != "" { + buffer.WriteString("\"GOSSIP_DNS_CONN_LIMIT=") + buffer.WriteString(os.Getenv("GOSSIP_DNS_CONN_LIMIT")) + buffer.WriteString("\" ") + } + // Pass in required credentials when using user-defined s3 endpoint if os.Getenv("S3_ENDPOINT") != "" { buffer.WriteString("\"S3_ENDPOINT=") diff --git a/nodeup/pkg/model/protokube.go b/nodeup/pkg/model/protokube.go index 7105afc2f9..232bd731f9 100644 --- a/nodeup/pkg/model/protokube.go +++ b/nodeup/pkg/model/protokube.go @@ -361,6 +361,15 @@ func (t *ProtokubeBuilder) ProtokubeEnvironmentVariables() string { // TODO write out an environments file for this. This is getting a tad long. + // Passin gossip dns connection limit + if os.Getenv("GOSSIP_DNS_CONN_LIMIT") != "" { + buffer.WriteString(" ") + buffer.WriteString("-e 'GOSSIP_DNS_CONN_LIMIT=") + buffer.WriteString(os.Getenv("GOSSIP_DNS_CONN_LIMIT")) + buffer.WriteString("'") + buffer.WriteString(" ") + } + // Pass in required credentials when using user-defined s3 endpoint if os.Getenv("AWS_REGION") != "" { buffer.WriteString(" ") diff --git a/pkg/model/bootstrapscript.go b/pkg/model/bootstrapscript.go index 20c5e64f1a..c597b9a70e 100644 --- a/pkg/model/bootstrapscript.go +++ b/pkg/model/bootstrapscript.go @@ -60,6 +60,11 @@ func (b *BootstrapScript) KubeEnv(ig *kops.InstanceGroup) (string, error) { func (b *BootstrapScript) buildEnvironmentVariables(cluster *kops.Cluster) (map[string]string, error) { env := make(map[string]string) + + if os.Getenv("GOSSIP_DNS_CONN_LIMIT") != "" { + env["GOSSIP_DNS_CONN_LIMIT"] = os.Getenv("GOSSIP_DNS_CONN_LIMIT") + } + if os.Getenv("S3_ENDPOINT") != "" { env["S3_ENDPOINT"] = os.Getenv("S3_ENDPOINT") env["S3_REGION"] = os.Getenv("S3_REGION") diff --git a/protokube/pkg/gossip/mesh/gossip.go b/protokube/pkg/gossip/mesh/gossip.go index 614e2a1157..d7766f2746 100644 --- a/protokube/pkg/gossip/mesh/gossip.go +++ b/protokube/pkg/gossip/mesh/gossip.go @@ -19,6 +19,7 @@ package mesh import ( "fmt" "net" + "os" "strconv" "time" @@ -39,10 +40,23 @@ type MeshGossiper struct { } func NewMeshGossiper(listen string, channelName string, nodeName string, password []byte, seeds gossip.SeedProvider) (*MeshGossiper, error) { + + connLimit := 64 + gossipDnsConnLimit := os.Getenv("GOSSIP_DNS_CONN_LIMIT") + if gossipDnsConnLimit != "" { + limit, err := strconv.Atoi(gossipDnsConnLimit) + if err != nil { + return nil, fmt.Errorf("cannot parse env GOSSIP_DNS_CONN_LIMIT value: %v", gossipDnsConnLimit) + } + connLimit = limit + } + + glog.Infof("gossip dns connection limit is:%d", connLimit) + meshConfig := mesh.Config{ ProtocolMinVersion: mesh.ProtocolMinVersion, Password: password, - ConnLimit: 64, + ConnLimit: connLimit, PeerDiscovery: true, //TrustedSubnets: []*net.IPNet{}, } From 8d3ad44137bb6fada942a85ea5cf601f89ccb83e Mon Sep 17 00:00:00 2001 From: liang Date: Wed, 2 May 2018 02:16:40 +0000 Subject: [PATCH 2/2] add err to log --- protokube/pkg/gossip/mesh/gossip.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protokube/pkg/gossip/mesh/gossip.go b/protokube/pkg/gossip/mesh/gossip.go index d7766f2746..336a560239 100644 --- a/protokube/pkg/gossip/mesh/gossip.go +++ b/protokube/pkg/gossip/mesh/gossip.go @@ -46,7 +46,7 @@ func NewMeshGossiper(listen string, channelName string, nodeName string, passwor if gossipDnsConnLimit != "" { limit, err := strconv.Atoi(gossipDnsConnLimit) if err != nil { - return nil, fmt.Errorf("cannot parse env GOSSIP_DNS_CONN_LIMIT value: %v", gossipDnsConnLimit) + return nil, fmt.Errorf("cannot parse env GOSSIP_DNS_CONN_LIMIT value: %v, err:%v", gossipDnsConnLimit, err) } connLimit = limit }