Browse Source

cluster: decouple getRegion() from finishRegion()

Signed-off-by: Alejandro Mery <amery@jpi.io>
Alejandro Mery 10 months ago
parent
commit
ae9f941bfc
  1. 13
      pkg/cluster/regions.go

13
pkg/cluster/regions.go

@ -147,7 +147,7 @@ func (m *Cluster) finishRegion(r *Region) {
r.m = m
sub := []string{}
for _, name := range r.Regions {
r2, ok := m.getRegion(name)
r2, ok := m.getFinishRegion(name)
if !ok {
m.warn(nil).WithField("region", name).Print("unknown region")
continue
@ -162,9 +162,7 @@ func (m *Cluster) finishRegion(r *Region) {
func (m *Cluster) getRegion(name string) (*Region, bool) {
for i := range m.Regions {
r := &m.Regions[i]
if name == r.Name {
m.finishRegion(r)
return r, true
}
}
@ -172,6 +170,15 @@ func (m *Cluster) getRegion(name string) (*Region, bool) {
return nil, false
}
func (m *Cluster) getFinishRegion(name string) (*Region, bool) {
if r, ok := m.getRegion(name); ok {
m.finishRegion(r)
return r, true
}
return nil, false
}
// SyncRegions writes to the file system the regions this [Zone]
// belongs to.
func (z *Zone) SyncRegions() error {

Loading…
Cancel
Save