1
0
Fork 0

Use same Raft port with DNS provider

This is what the docs have always said DNS disco does.
master
Philip O'Toole 10 months ago
parent 01b9355caa
commit 2f1ddc8236

@ -11,6 +11,7 @@ import (
"path/filepath"
"reflect"
"runtime"
"strconv"
"strings"
"time"
)
@ -257,11 +258,13 @@ func (c *Config) Validate() error {
hadv, HTTPAddrFlag, HTTPAdvAddrFlag)
}
if _, _, err := net.SplitHostPort(c.RaftAddr); err != nil {
if _, rp, err := net.SplitHostPort(c.RaftAddr); err != nil {
return errors.New("raft bind address not valid")
} else if _, err := strconv.Atoi(rp); err != nil {
return errors.New("raft bind port not valid")
}
radv, _, err := net.SplitHostPort(c.RaftAdv)
radv, rp, err := net.SplitHostPort(c.RaftAdv)
if err != nil {
return errors.New("raft advertised address not valid")
}
@ -269,6 +272,9 @@ func (c *Config) Validate() error {
return fmt.Errorf("advertised Raft address is not routable (%s), specify it via -%s or -%s",
radv, RaftAddrFlag, RaftAdvAddrFlag)
}
if _, err := strconv.Atoi(rp); err != nil {
return errors.New("raft advertised port is not valid")
}
if c.RaftAdv == c.HTTPAdv {
return errors.New("advertised HTTP and Raft addresses must differ")
@ -336,6 +342,20 @@ func (c *Config) HTTPURL() string {
return fmt.Sprintf("%s://%s", apiProto, c.HTTPAdv)
}
// RaftPort returns the port on which the Raft system is listening. Validate must
// have been called before calling this method.
func (c *Config) RaftPort() int {
_, port, err := net.SplitHostPort(c.RaftAddr)
if err != nil {
panic("RaftAddr not valid")
}
p, err := strconv.Atoi(port)
if err != nil {
panic("RaftAddr port not valid")
}
return p
}
// DiscoConfigReader returns a ReadCloser providing access to the Disco config.
// The caller must call close on the ReadCloser when finished with it. If no
// config was supplied, it returns nil.

@ -515,7 +515,7 @@ func createCluster(cfg *Config, hasPeers bool, client *cluster.Client, str *stor
if err != nil {
return fmt.Errorf("error reading DNS configuration: %s", err.Error())
}
provider = dns.New(dnsCfg)
provider = dns.NewWithPort(dnsCfg, cfg.RaftPort())
} else {
dnssrvCfg, err := dnssrv.NewConfigFromReader(rc)

@ -19,7 +19,7 @@ require (
github.com/mkideal/pkg v0.1.3
github.com/rqlite/go-sqlite3 v1.29.0
github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48
github.com/rqlite/rqlite-disco-clients v0.0.0-20230505011544-70f7602795ff
github.com/rqlite/rqlite-disco-clients v0.0.0-20231121120431-b2b3f3f258b8
github.com/rqlite/sql v0.0.0-20221103124402-8f9ff0ceb8f0
go.etcd.io/bbolt v1.3.7
go.etcd.io/etcd/client/v3 v3.5.9 // indirect

@ -1198,6 +1198,8 @@ github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48 h1:NZ62M+kT0
github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48/go.mod h1:CRnsxgy5G8fAf5J+AM0yrsSdxXHKkIYOaq2sm+Q4DYc=
github.com/rqlite/rqlite-disco-clients v0.0.0-20230505011544-70f7602795ff h1:NRe0uU1s3f2nYMV+xaASReg0w13FR+pLMn/kVUSuao4=
github.com/rqlite/rqlite-disco-clients v0.0.0-20230505011544-70f7602795ff/go.mod h1:pym85nj6JnCI7rM9RxTZ4cubkTQyyg7uLwVydso9B80=
github.com/rqlite/rqlite-disco-clients v0.0.0-20231121120431-b2b3f3f258b8 h1:yQOGslcEn2k4E0WRrtaIK6SqaX6MS/DYBhuAW01VYvw=
github.com/rqlite/rqlite-disco-clients v0.0.0-20231121120431-b2b3f3f258b8/go.mod h1:pym85nj6JnCI7rM9RxTZ4cubkTQyyg7uLwVydso9B80=
github.com/rqlite/sql v0.0.0-20221103124402-8f9ff0ceb8f0 h1:C8DZB5okjhCSd7zvkOM+zxGz7S6ulUFIL34bpkqFk+0=
github.com/rqlite/sql v0.0.0-20221103124402-8f9ff0ceb8f0/go.mod h1:ib9zVtNgRKiGuoMyUqqL5aNpk+r+++YlyiVIkclVqPg=
github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=

Loading…
Cancel
Save