configure corrosion bootstrap peers when initialising a machine

This commit is contained in:
Pavel Sviderski
2024-09-26 20:36:13 +10:00
parent b25938acc1
commit 69c9167355
2 changed files with 11 additions and 0 deletions
+1
View File
@@ -32,6 +32,7 @@ type DBConfig struct {
type GossipConfig struct { type GossipConfig struct {
Addr netip.AddrPort `toml:"addr"` Addr netip.AddrPort `toml:"addr"`
Bootstrap []string `toml:"bootstrap"`
Plaintext bool `toml:"plaintext"` Plaintext bool `toml:"plaintext"`
} }
+10
View File
@@ -258,6 +258,15 @@ func (m *Machine) configureCorrosion(dataDir string) error {
} }
corroConfigPath := filepath.Join(dataDir, "config.toml") corroConfigPath := filepath.Join(dataDir, "config.toml")
// TODO: use a partial list of machine peers for bootstrapping if the cluster is large.
var bootstrap []string
for _, peer := range m.state.Network.Peers {
if peer.Subnet == nil {
// Skip non-machine peers.
continue
}
bootstrap = append(bootstrap, netip.AddrPortFrom(peer.ManagementIP, corrosion.DefaultGossipPort).String())
}
cfg := corrosion.Config{ cfg := corrosion.Config{
DB: corrosion.DBConfig{ DB: corrosion.DBConfig{
Path: filepath.Join(dataDir, "store.db"), Path: filepath.Join(dataDir, "store.db"),
@@ -265,6 +274,7 @@ func (m *Machine) configureCorrosion(dataDir string) error {
}, },
Gossip: corrosion.GossipConfig{ Gossip: corrosion.GossipConfig{
Addr: netip.AddrPortFrom(m.state.Network.ManagementIP, corrosion.DefaultGossipPort), Addr: netip.AddrPortFrom(m.state.Network.ManagementIP, corrosion.DefaultGossipPort),
Bootstrap: bootstrap,
Plaintext: true, Plaintext: true,
}, },
API: corrosion.APIConfig{ API: corrosion.APIConfig{