diff --git a/pkg/zones/env.go b/pkg/zones/env.go index 59eaadc..2e2ae95 100644 --- a/pkg/zones/env.go +++ b/pkg/zones/env.go @@ -88,7 +88,7 @@ func getRingZeroGatewayID(z *Zone) int { firstNodeID = nodeID } - if _, found := p.getRingInfo(0); found { + if p.IsGateway() { gatewayID = nodeID } diff --git a/pkg/zones/machine.go b/pkg/zones/machine.go index 5966ae7..2348cf7 100644 --- a/pkg/zones/machine.go +++ b/pkg/zones/machine.go @@ -58,6 +58,18 @@ func (m *Machine) FullName() string { return m.Name } +// IsGateway tells if the Machine is a ring0 gateway +func (m *Machine) IsGateway() bool { + m.mu.Lock() + defer m.mu.Unlock() + + if ri, found := m.getRingInfo(0); found { + return ri.Enabled + } + + return false +} + func (m *Machine) getPeerByName(name string) (*Machine, bool) { return m.zone.zones.GetMachineByName(name) }