cluster: introduce Machine.Inactive flag #38

Merged
amery merged 3 commits from pr-amery-dns-ignore into main 2023-10-30 20:44:42 +01:00
3 changed files with 10 additions and 2 deletions
Showing only changes of commit 892d849740 - Show all commits
+1 -1
View File
@@ -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, true, p.PublicAddresses...)
err = mgr.AddHost(ctx, z.Name, p.ID, p.IsActive(), p.PublicAddresses...)
return err != nil
})
+6
View File
@@ -15,6 +15,7 @@ type Machine struct {
ID int
Name string `json:"-" yaml:"-"`
Inactive bool `json:"inactive,omitempty" yaml:"inactive,omitempty"`
Outdated
Review

Please name the field Active

Please name the field `Active`
Outdated
Review

Active breaks zero-value rules, everything would become inactive by default

`Active` breaks zero-value rules, everything would become inactive by default
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"`
@@ -43,6 +44,11 @@ func (m *Machine) FullName() string {
return strings.Join(name, ".")
}
// IsActive indicates the machine is to be included in regions' DNS entries
func (m *Machine) IsActive() bool {
return !m.Inactive
}
amery marked this conversation as resolved Outdated
Outdated
Review
func (m *Machine) IsActive() bool {
	return m.Active
}
```go func (m *Machine) IsActive() bool { return m.Active }
// IsGateway tells if the Machine is a ring0 gateway
func (m *Machine) IsGateway() bool {
_, ok := m.getRingInfo(0)
+3 -1
View File
@@ -32,7 +32,9 @@ func (r *Region) ForEachMachine(fn func(*Machine) bool) {
var term bool
z.ForEachMachine(func(p *Machine) bool {
term = fn(p)
if p.IsActive() {
amery marked this conversation as resolved Outdated
Outdated
Review
if p.IsActive() {
...
```go if p.IsActive() { ... ```
term = fn(p)
}
return term
})