From 69c91673552410070af4794cb926013f70cb6eab Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Thu, 26 Sep 2024 20:36:13 +1000 Subject: [PATCH] configure corrosion bootstrap peers when initialising a machine --- internal/machine/corrosion/config.go | 1 + internal/machine/machine.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/internal/machine/corrosion/config.go b/internal/machine/corrosion/config.go index 0fe07908..1f709981 100644 --- a/internal/machine/corrosion/config.go +++ b/internal/machine/corrosion/config.go @@ -32,6 +32,7 @@ type DBConfig struct { type GossipConfig struct { Addr netip.AddrPort `toml:"addr"` + Bootstrap []string `toml:"bootstrap"` Plaintext bool `toml:"plaintext"` } diff --git a/internal/machine/machine.go b/internal/machine/machine.go index b9d40bd5..87303554 100644 --- a/internal/machine/machine.go +++ b/internal/machine/machine.go @@ -258,6 +258,15 @@ func (m *Machine) configureCorrosion(dataDir string) error { } 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{ DB: corrosion.DBConfig{ Path: filepath.Join(dataDir, "store.db"), @@ -265,6 +274,7 @@ func (m *Machine) configureCorrosion(dataDir string) error { }, Gossip: corrosion.GossipConfig{ Addr: netip.AddrPortFrom(m.state.Network.ManagementIP, corrosion.DefaultGossipPort), + Bootstrap: bootstrap, Plaintext: true, }, API: corrosion.APIConfig{