Fix casing on keepalive
This commit is contained in:
parent
dca1a2b5ae
commit
331c225c36
@ -56,7 +56,7 @@ const (
|
||||
lastSeenAnnotationKey = "kilo.squat.ai/last-seen"
|
||||
leaderAnnotationKey = "kilo.squat.ai/leader"
|
||||
locationAnnotationKey = "kilo.squat.ai/location"
|
||||
persistentKeepAliveKey = "kilo.squat.ai/persistent-keepalive"
|
||||
persistentKeepaliveKey = "kilo.squat.ai/persistent-keepalive"
|
||||
wireGuardIPAnnotationKey = "kilo.squat.ai/wireguard-ip"
|
||||
|
||||
regionLabelKey = "topology.kubernetes.io/region"
|
||||
@ -263,13 +263,13 @@ func translateNode(node *v1.Node) *mesh.Node {
|
||||
if !ok {
|
||||
internalIP = node.ObjectMeta.Annotations[internalIPAnnotationKey]
|
||||
}
|
||||
// Set Wireguard PersistentKeepAlive setting for the node.
|
||||
var persistentKeepAlive int64
|
||||
if keepAlive, ok := node.ObjectMeta.Annotations[persistentKeepAliveKey]; !ok {
|
||||
persistentKeepAlive = 0
|
||||
// Set Wireguard PersistentKeepalive setting for the node.
|
||||
var persistentKeepalive int64
|
||||
if keepAlive, ok := node.ObjectMeta.Annotations[persistentKeepaliveKey]; !ok {
|
||||
persistentKeepalive = 0
|
||||
} else {
|
||||
if persistentKeepAlive, err = strconv.ParseInt(keepAlive, 10, 64); err != nil {
|
||||
persistentKeepAlive = 0
|
||||
if persistentKeepalive, err = strconv.ParseInt(keepAlive, 10, 64); err != nil {
|
||||
persistentKeepalive = 0
|
||||
}
|
||||
}
|
||||
var lastSeen int64
|
||||
@ -292,7 +292,7 @@ func translateNode(node *v1.Node) *mesh.Node {
|
||||
Leader: leader,
|
||||
Location: location,
|
||||
Name: node.Name,
|
||||
PersistentKeepAlive: int(persistentKeepAlive),
|
||||
PersistentKeepalive: int(persistentKeepalive),
|
||||
Subnet: subnet,
|
||||
// WireGuardIP can fail to parse if the node is not a leader or if
|
||||
// the node's agent has not yet reconciled. In either case, the IP
|
||||
|
@ -114,10 +114,10 @@ func TestTranslateNode(t *testing.T) {
|
||||
{
|
||||
name: "wireguard persistent keepalive override",
|
||||
annotations: map[string]string{
|
||||
persistentKeepAliveKey: "25",
|
||||
persistentKeepaliveKey: "25",
|
||||
},
|
||||
out: &mesh.Node{
|
||||
PersistentKeepAlive: 25,
|
||||
PersistentKeepalive: 25,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -148,7 +148,7 @@ func TestTranslateNode(t *testing.T) {
|
||||
lastSeenAnnotationKey: "1000000000",
|
||||
leaderAnnotationKey: "",
|
||||
locationAnnotationKey: "b",
|
||||
persistentKeepAliveKey: "25",
|
||||
persistentKeepaliveKey: "25",
|
||||
wireGuardIPAnnotationKey: "10.4.0.1/16",
|
||||
},
|
||||
labels: map[string]string{
|
||||
@ -161,7 +161,7 @@ func TestTranslateNode(t *testing.T) {
|
||||
LastSeen: 1000000000,
|
||||
Leader: true,
|
||||
Location: "b",
|
||||
PersistentKeepAlive: 25,
|
||||
PersistentKeepalive: 25,
|
||||
Subnet: &net.IPNet{IP: net.ParseIP("10.2.1.0"), Mask: net.CIDRMask(24, 32)},
|
||||
WireGuardIP: &net.IPNet{IP: net.ParseIP("10.4.0.1"), Mask: net.CIDRMask(16, 32)},
|
||||
},
|
||||
|
@ -82,7 +82,7 @@ type Node struct {
|
||||
Leader bool
|
||||
Location string
|
||||
Name string
|
||||
PersistentKeepAlive int
|
||||
PersistentKeepalive int
|
||||
Subnet *net.IPNet
|
||||
WireGuardIP *net.IPNet
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ type segment struct {
|
||||
hostnames []string
|
||||
// leader is the index of the leader of the segment.
|
||||
leader int
|
||||
// persistentKeepAlive is the interval in seconds of the emission
|
||||
// persistentKeepalive is the interval in seconds of the emission
|
||||
// of keepalive packets to the peer.
|
||||
persistentKeepAlive int
|
||||
persistentKeepalive int
|
||||
// privateIPs is a slice of private IPs of all peers in the segment.
|
||||
privateIPs []net.IP
|
||||
// wireGuardIP is the allocated IP address of the WireGuard
|
||||
@ -128,7 +128,7 @@ func NewTopology(nodes map[string]*Node, peers map[string]*Peer, granularity Gra
|
||||
hostnames: hostnames,
|
||||
leader: leader,
|
||||
privateIPs: privateIPs,
|
||||
persistentKeepAlive: topoMap[location][leader].PersistentKeepAlive,
|
||||
persistentKeepalive: topoMap[location][leader].PersistentKeepalive,
|
||||
})
|
||||
}
|
||||
// Sort the Topology segments so the result is stable.
|
||||
@ -339,7 +339,7 @@ func (t *Topology) Conf() *wireguard.Conf {
|
||||
Port: uint32(t.port),
|
||||
},
|
||||
PublicKey: s.key,
|
||||
PersistentKeepalive: s.persistentKeepAlive,
|
||||
PersistentKeepalive: s.persistentKeepalive,
|
||||
}
|
||||
c.Peers = append(c.Peers, peer)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user