two/internal/watchdog/check_public.go
GnomeZworc 26095062c8
f-87: agent: bridge public = interfaces.internet, watchdog du segment #87
Le veth vp-<id>-e rejoint cfg.PublicBridge() (interfaces.internet, br-public
par défaut, jamais default_interface). Le watchdog signale un bridge public
absent, éteint ou sans port VXLAN. config.exemple.yml : internet: br-public.

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
2026-10-26 23:19:47 +01:00

39 lines
1.1 KiB
Go

package watchdog
import (
"fmt"
configuration "git.g3e.fr/syonad/two/internal/config/agent"
"git.g3e.fr/syonad/two/internal/netif"
"git.g3e.fr/syonad/two/internal/watchdog/notify"
)
const kindPublic = "public"
type publicProbe interface {
LinkProblem(name string) string
VxlanPorts(bridge string) ([]string, error)
}
type systemPublicProbe struct{}
func (systemPublicProbe) LinkProblem(name string) string { return linkProblem(name) }
func (systemPublicProbe) VxlanPorts(bridge string) ([]string, error) {
return netif.BridgeVxlanPorts(bridge)
}
func CheckPublicSegment(cfg *configuration.Config, p publicProbe, n notify.Notifier) {
bridge := cfg.PublicBridge()
if problem := p.LinkProblem(bridge); problem != "" {
n.Notify(kindPublic, bridge, problem+" (public bridge, interfaces.internet): the vpcs of this host have no public segment")
return
}
ports, err := p.VxlanPorts(bridge)
switch {
case err != nil:
n.Notify(kindPublic, bridge, fmt.Sprintf("vxlan ports unreadable: %v", err))
case len(ports) == 0:
n.Notify(kindPublic, bridge, "no vxlan port: the public segment is unreachable from this host")
}
}