small pixel drawing of a pufferfish cascade

copy consuls default ports
Jes Olson j3s@c3f.net
Mon, 20 Feb 2023 17:00:12 -0800
commit

d1fd7dafe17d7c5df8b9cd8d5d6a929e7949643a

parent

abafaa3ad00eeeadd0eab20ef9e1e9ca3ee5d981

M agent/agent.goagent/agent.go

@@ -107,8 +107,8 @@ // TODO: some of these serf settings were cargo-culted

// from consul[1]. re-examine them eventually. serfConfig.EnableNameConflictResolution = false serfConfig.LeavePropagateDelay = 3 * time.Second - serfConfig.MemberlistConfig.BindAddr = config.BindAddr.IP.String() - serfConfig.MemberlistConfig.BindPort = config.BindAddr.Port + serfConfig.MemberlistConfig.BindAddr = config.SerfBindAddr.IP.String() + serfConfig.MemberlistConfig.BindPort = config.SerfBindAddr.Port serfConfig.MemberlistConfig.DeadNodeReclaimTime = 30 * time.Second serfConfig.MinQueueDepth = 4096 serfConfig.NodeName = config.NodeName
M agent/config.goagent/config.go

@@ -5,8 +5,8 @@ "net"

"os" ) -const DefaultSerfPort int = 4443 -const DefaultClientPort int = 4444 +const DefaultSerfPort int = 8301 +const DefaultAPIPort int = 8500 func DefaultConfig() *Config { hostname, err := os.Hostname()

@@ -16,16 +16,16 @@ }

// TODO: figure out how to default the listeners cfg := Config{} - cfg.BindAddr = &net.TCPAddr{IP: []byte{0, 0, 0, 0}, Port: DefaultSerfPort} - cfg.ClientAddr = &net.TCPAddr{IP: []byte{127, 0, 0, 1}, Port: DefaultClientPort} + cfg.SerfBindAddr = &net.TCPAddr{IP: net.ParseIP("0.0.0.0"), Port: DefaultSerfPort} + cfg.APIBindAddr = &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: DefaultAPIPort} cfg.NodeName = hostname return &cfg } type Config struct { - BindAddr *net.TCPAddr - ClientAddr *net.TCPAddr - NodeName string - StartJoin []string + SerfBindAddr *net.TCPAddr + APIBindAddr *net.TCPAddr + NodeName string + StartJoin []string }
M command/agent/agent.gocommand/agent/agent.go

@@ -1,6 +1,7 @@

package agent import ( + "flag" "fmt" "log" "net"

@@ -18,7 +19,45 @@ // gracefulTimeout controls how long we wait before forcefully terminating

// note that this value interacts with serf's LeavePropagateDelay config const gracefulTimeout = 10 * time.Second +const usage = `cascade agent [options] + + this command starts the cascade agent, which is responsible + for basically everything, including service registration, + health checking, cluster membership, and hosting the API. + +common options: + + -node=<name> + name of this node, must be globally unique (default = hostname) + +bind options: + + -api-bind=<addr> + address the http api binds to (default = 127.0.0.1:8500) + !!do not expose the api publicly!! + + -dns-bind=<addr> + address the DNS resolver to (default = 127.0.0.1:8600) + !!do not expose the api publicly!! + + -serf-bind=<addr> + address the serf gossip cluster binds to (default = 0.0.0.0:8301) +` + +var ( + apiBindAddr string + serfBindAddr string +) + func Run(args []string) { + flags := flag.NewFlagSet("agent", flag.ContinueOnError) + flags.Usage = func() { fmt.Printf(usage) } + flags.StringVar(&serfBindAddr, "serf-bind", "", "") + if err := flags.Parse(args); err != nil { + fmt.Println(err) + os.Exit(1) + } + config, err := configureAgent() if err != nil { fmt.Println(err)

@@ -111,7 +150,7 @@ func configureAgent() (*agent.Config, error) {

config := agent.DefaultConfig() // CASCADE_BIND=192.168.0.15:12345 if os.Getenv("CASCADE_BIND") != "" { - err := parseFlagAddress(os.Getenv("CASCADE_BIND"), config.BindAddr) + err := parseFlagAddress(os.Getenv("CASCADE_BIND"), config.SerfBindAddr) if err != nil { return nil, err }
M command/agent/agent_test.gocommand/agent/agent_test.go

@@ -18,7 +18,7 @@ cases := []c{

{ inputAddr: "127.0.0.1", expectIP: "127.0.0.1", - expectPort: 4443, + expectPort: 8301, }, { inputAddr: "127.0.0.1:6969",

@@ -33,37 +33,37 @@ },

{ inputAddr: "127.0.0.3:", expectIP: "127.0.0.3", - expectPort: 4443, + expectPort: 8301, }, // error cases { inputAddr: "", expectIP: "0.0.0.0", - expectPort: 4443, + expectPort: 8301, expectErrStr: "Error parsing blank address", }, { inputAddr: ":1234", expectIP: "0.0.0.0", - expectPort: 4443, + expectPort: 8301, expectErrStr: "Error parsing blank address", }, { inputAddr: "127.0.0.1:abcd", expectIP: "0.0.0.0", - expectPort: 4443, + expectPort: 8301, expectErrStr: "Error parsing port", }, { inputAddr: "127.0.0.256:6969", expectIP: "0.0.0.0", - expectPort: 4443, + expectPort: 8301, expectErrStr: "Error parsing address", }, } for _, tc := range cases { - addr := agent.DefaultConfig().BindAddr + addr := agent.DefaultConfig().SerfBindAddr expectErr := tc.expectErrStr != "" err := parseFlagAddress(tc.inputAddr, addr)
M command/list/nodes.gocommand/list/nodes.go

@@ -4,11 +4,9 @@ import (

"fmt" ) -const usage = `usage: cascade list <command> - -commands: - cascade list nodes - cascade list services +const usage = `cascade list|ls nodes +cascade list|ls members +cascade list|ls services ` func Run(args []string) {