Browse Source

cluster: remove k8s_token files from zones on write if found

Signed-off-by: Alejandro Mery <amery@jpi.io>
Alejandro Mery 9 months ago
parent
commit
299556544d
  1. 22
      pkg/cluster/regions.go

22
pkg/cluster/regions.go

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

Loading…
Cancel
Save