Compare commits
6 Commits
ce7eac8e58
...
v0.6.11
| Author | SHA1 | Date | |
|---|---|---|---|
| a910bba406 | |||
| 5ef6d45ef7 | |||
| 99998dc7e8 | |||
| 892d849740 | |||
| 125a4c0dbe | |||
| 7c811d7813 |
+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, true, p.PublicAddresses...)
|
||||
err = mgr.AddHost(ctx, z.Name, p.ID, p.IsActive(), p.PublicAddresses...)
|
||||
return err != nil
|
||||
})
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ 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"`
|
||||
@@ -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
|
||||
}
|
||||
|
||||
// IsGateway tells if the Machine is a ring0 gateway
|
||||
func (m *Machine) IsGateway() bool {
|
||||
_, ok := m.getRingInfo(0)
|
||||
|
||||
@@ -3,6 +3,7 @@ package cluster
|
||||
import (
|
||||
"context"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -81,7 +82,30 @@ func (m *Machine) scan(_ *ScanOptions) error {
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
// scanWrapUp is called once all machines have been scanned
|
||||
|
||||
@@ -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() {
|
||||
term = fn(p)
|
||||
}
|
||||
return term
|
||||
})
|
||||
|
||||
|
||||
@@ -107,6 +107,11 @@ func (ep EndpointAddress) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalText loads an endpoint address from text data
|
||||
func (ep *EndpointAddress) UnmarshalText(b []byte) error {
|
||||
return ep.FromString(string(b))
|
||||
}
|
||||
|
||||
// FromString sets the EndpointAddress from a given "[host]:port"
|
||||
func (ep *EndpointAddress) FromString(s string) error {
|
||||
host, port, err := core.SplitHostPort(s)
|
||||
|
||||
@@ -51,6 +51,28 @@ func (pub PublicKey) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalText loads the value from base64
|
||||
func (key *PrivateKey) UnmarshalText(b []byte) error {
|
||||
v, err := PrivateKeyFromBase64(string(b))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*key = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalText loads the value from base64
|
||||
func (pub *PublicKey) UnmarshalText(b []byte) error {
|
||||
v, err := PublicKeyFromBase64(string(b))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*pub = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON encodes the key for JSON, omitting empty.
|
||||
func (key PrivateKey) MarshalJSON() ([]byte, error) {
|
||||
return encodeKeyJSON(key.String())
|
||||
|
||||
Reference in New Issue
Block a user