Browse Source

cluster: mark Machine as Inactive if the "region" file contains "none"

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/38/head
Alejandro Mery 1 year ago
parent
commit
99998dc7e8
  1. 26
      pkg/cluster/machine_scan.go

26
pkg/cluster/machine_scan.go

@ -3,6 +3,7 @@ package cluster
import ( import (
"context" "context"
"net/netip" "net/netip"
"os"
"strconv" "strconv"
"strings" "strings"
"time" "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 // scanWrapUp is called once all machines have been scanned

Loading…
Cancel
Save