Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change gossip dns conn limit by ENV #5077

Merged
merged 2 commits into from
Jul 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions nodeup/pkg/bootstrap/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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=")
Expand Down
9 changes: 9 additions & 0 deletions nodeup/pkg/model/protokube.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(" ")
Expand Down
5 changes: 5 additions & 0 deletions pkg/model/bootstrapscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 15 additions & 1 deletion protokube/pkg/gossip/mesh/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package mesh
import (
"fmt"
"net"
"os"
"strconv"
"time"

Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add err to message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks.

}
connLimit = limit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can just be above,

connLimit, err := strconv.Atoi(gossipDnsConnLimit)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we put all in one statement, it will output the following error(create a new inner scope var):

protokube/pkg/gossip/mesh/gossip.go:47:3: connLimit declared and not used

so i split it :)

}

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{},
}
Expand Down