Compare commits

..

2 Commits

Author SHA1 Message Date
amery a725b66d14 cluster: mark Machine as Inactive if the "region" file contains "none"
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 18:52:38 +00:00
amery 851274954e cluster: introduce Machine.Inactive flag
if a Machine is Inactive, it won't be included on the DNS
aliases for the zone or it's regions.

Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 18:52:34 +00:00
5 changed files with 4 additions and 31 deletions
+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, p.IsActive(), p.PublicAddresses...)
err = mgr.AddHost(ctx, z.Name, p.ID, p.Active(), p.PublicAddresses...)
return err != nil
})
+2 -2
View File
@@ -44,8 +44,8 @@ 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 {
// Active indicates the machine is to be included in regions' DNS entries
func (m *Machine) Active() bool {
return !m.Inactive
}
+1 -1
View File
@@ -32,7 +32,7 @@ func (r *Region) ForEachMachine(fn func(*Machine) bool) {
var term bool
z.ForEachMachine(func(p *Machine) bool {
if p.IsActive() {
if p.Active() {
term = fn(p)
}
return term
-5
View File
@@ -107,11 +107,6 @@ 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)
-22
View File
@@ -51,28 +51,6 @@ 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())