cluster: generate ring keys on scan if missing

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-10-27 19:00:06 +00:00
parent 543824a54a
commit e5639b2f4e
4 changed files with 40 additions and 2 deletions
+18 -1
View File
@@ -68,7 +68,8 @@ func (m *Machine) setID() error {
return nil
}
func (m *Machine) scan(opts *ScanOptions) error {
// scan is called once we know about all zones and machine names
func (m *Machine) scan(_ *ScanOptions) error {
for i := 0; i < RingsCount; i++ {
if err := m.tryApplyWireguardConfig(i); err != nil {
m.error(err).
@@ -80,6 +81,22 @@ func (m *Machine) scan(opts *ScanOptions) error {
}
}
return nil
}
// scanWrapUp is called once all machines have been scanned
func (m *Machine) scanWrapUp(opts *ScanOptions) error {
for _, ri := range m.Rings {
if err := m.setRingDefaults(ri); err != nil {
m.error(err).
WithField("subsystem", "wireguard").
WithField("node", m.Name).
WithField("ring", ri.Ring).
Print()
return err
}
}
if !opts.DontResolvePublicAddresses {
return m.UpdatePublicAddresses()
}