Browse Source

cluster: remove k8s_token files from zones on write if found

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/42/head
Alejandro Mery 9 months ago
parent
commit
019143820f
  1. 22
      pkg/cluster/regions.go

22
pkg/cluster/regions.go

@ -199,11 +199,7 @@ func (z *Zone) SyncRegions() error {
err := z.syncZoneRegions() err := z.syncZoneRegions()
if err == nil { if err == nil {
z.ForEachMachine(func(p *Machine) bool { z.ForEachMachine(func(p *Machine) bool {
if p.IsActive() { err = z.syncMachineRegions(p)
err = p.RemoveFile("region")
} else {
err = p.WriteStringFile("none\n", "region")
}
return err != nil return err != nil
}) })
} }
@ -211,6 +207,22 @@ func (z *Zone) SyncRegions() error {
return err return err
} }
func (*Zone) syncMachineRegions(p *Machine) error {
var err error
if p.IsActive() {
err = p.RemoveFile("region")
} else {
err = p.WriteStringFile("none\n", "region")
}
if err == nil {
err = p.RemoveFile(RegionClusterTokenFileName)
}
return err
}
func (z *Zone) syncZoneRegions() error { func (z *Zone) syncZoneRegions() error {
name := filepath.Join(z.Name, ZoneRegionsFileName) name := filepath.Join(z.Name, ZoneRegionsFileName)

Loading…
Cancel
Save