Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a6cdfcfe8 | |||
| 8866650a47 | |||
| b1544c251c | |||
| 7ea3906d63 | |||
| 6e0bf95fdf | |||
| 472b014a74 | |||
| 30b15da87d | |||
| da38250465 | |||
| bdf0192ac5 | |||
| 194f03c86a |
+1
-1
@@ -52,7 +52,7 @@ func populateDNSManager(mgr *dns.Manager, m *cluster.Cluster) error {
|
||||
|
||||
m.ForEachZone(func(z *cluster.Zone) bool {
|
||||
z.ForEachMachine(func(p *cluster.Machine) bool {
|
||||
err = mgr.AddHost(ctx, z.Name, p.ID, p.Active(), p.PublicAddresses...)
|
||||
err = mgr.AddHost(ctx, z.Name, p.ID, true, p.PublicAddresses...)
|
||||
return err != nil
|
||||
})
|
||||
|
||||
|
||||
@@ -67,6 +67,15 @@ func (m *Cluster) ReadFile(name string, args ...any) ([]byte, error) {
|
||||
return fs.ReadFile(m.dir, name)
|
||||
}
|
||||
|
||||
// MkdirAll creates directories relative to the cluster's config directory
|
||||
func (m *Cluster) MkdirAll(name string, args ...any) error {
|
||||
if len(args) > 0 {
|
||||
name = fmt.Sprintf(name, args...)
|
||||
}
|
||||
|
||||
return fs.MkdirAll(m.dir, name, 0755)
|
||||
}
|
||||
|
||||
// ReadLines reads a file from the cluster's config directory,
|
||||
// split by lines, trimmed, and accepting `#` to comment lines out.
|
||||
func (m *Cluster) ReadLines(name string, args ...any) ([]string, error) {
|
||||
@@ -104,12 +113,3 @@ func (m *Cluster) WriteStringFile(value string, name string, args ...any) error
|
||||
_, err = buf.WriteTo(f)
|
||||
return err
|
||||
}
|
||||
|
||||
// MkdirAll creates directories relative to the cluster's config directory
|
||||
func (m *Cluster) MkdirAll(name string, args ...any) error {
|
||||
if len(args) > 0 {
|
||||
name = fmt.Sprintf(name, args...)
|
||||
}
|
||||
|
||||
return fs.MkdirAll(m.dir, name, 0755)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ type Machine struct {
|
||||
ID int
|
||||
Name string `json:"-" yaml:"-"`
|
||||
|
||||
Inactive bool `json:"inactive,omitempty" yaml:"inactive,omitempty"`
|
||||
CephMonitor bool `json:"ceph_monitor,omitempty" yaml:"ceph_monitor,omitempty"`
|
||||
PublicAddresses []netip.Addr `json:"public,omitempty" yaml:"public,omitempty"`
|
||||
Rings []*RingInfo `json:"rings,omitempty" yaml:"rings,omitempty"`
|
||||
@@ -44,11 +43,6 @@ func (m *Machine) FullName() string {
|
||||
return strings.Join(name, ".")
|
||||
}
|
||||
|
||||
// Active indicates the machine is to be included in regions' DNS entries
|
||||
func (m *Machine) Active() bool {
|
||||
return !m.Inactive
|
||||
}
|
||||
|
||||
// IsGateway tells if the Machine is a ring0 gateway
|
||||
func (m *Machine) IsGateway() bool {
|
||||
_, ok := m.getRingInfo(0)
|
||||
|
||||
@@ -53,14 +53,6 @@ func (m *Machine) ReadFile(name string, args ...any) ([]byte, error) {
|
||||
return m.zone.zones.ReadFile(fullName)
|
||||
}
|
||||
|
||||
// ReadLines reads a file from the machine's config directory,
|
||||
// split by lines, trimmed, and accepting `#` to comment lines out.
|
||||
func (m *Machine) ReadLines(name string, args ...any) ([]string, error) {
|
||||
fullName := m.getFilename(name, args...)
|
||||
|
||||
return m.zone.zones.ReadLines(fullName)
|
||||
}
|
||||
|
||||
// WriteStringFile writes the given content to a file on the machine's config directory
|
||||
func (m *Machine) WriteStringFile(value string, name string, args ...any) error {
|
||||
fullName := m.getFilename(name, args...)
|
||||
|
||||
@@ -3,7 +3,6 @@ package cluster
|
||||
import (
|
||||
"context"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -82,30 +81,7 @@ func (m *Machine) scan(_ *ScanOptions) error {
|
||||
}
|
||||
}
|
||||
|
||||
return m.loadInactive()
|
||||
}
|
||||
|
||||
func (m *Machine) loadInactive() error {
|
||||
data, err := m.ReadLines("region")
|
||||
switch {
|
||||
case os.IsNotExist(err):
|
||||
// no file
|
||||
return nil
|
||||
case err != nil:
|
||||
// read error
|
||||
return err
|
||||
default:
|
||||
// look for "none"
|
||||
for _, r := range data {
|
||||
switch r {
|
||||
case "none":
|
||||
m.Inactive = true
|
||||
default:
|
||||
m.Inactive = false
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// scanWrapUp is called once all machines have been scanned
|
||||
|
||||
@@ -32,9 +32,7 @@ func (r *Region) ForEachMachine(fn func(*Machine) bool) {
|
||||
var term bool
|
||||
|
||||
z.ForEachMachine(func(p *Machine) bool {
|
||||
if p.Active() {
|
||||
term = fn(p)
|
||||
}
|
||||
term = fn(p)
|
||||
return term
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user