From 331c225c36b5586a199efa425d970c4eab4b1228 Mon Sep 17 00:00:00 2001 From: Francis Nguyen Date: Tue, 11 Feb 2020 21:34:28 -0700 Subject: [PATCH] Fix casing on keepalive --- pkg/k8s/backend.go | 16 ++++++++-------- pkg/k8s/backend_test.go | 8 ++++---- pkg/mesh/mesh.go | 2 +- pkg/mesh/topology.go | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pkg/k8s/backend.go b/pkg/k8s/backend.go index 2317cd5..6620735 100644 --- a/pkg/k8s/backend.go +++ b/pkg/k8s/backend.go @@ -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 diff --git a/pkg/k8s/backend_test.go b/pkg/k8s/backend_test.go index c6e96bf..a0f8afe 100644 --- a/pkg/k8s/backend_test.go +++ b/pkg/k8s/backend_test.go @@ -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)}, }, diff --git a/pkg/mesh/mesh.go b/pkg/mesh/mesh.go index 4b84f2d..b47a0ea 100644 --- a/pkg/mesh/mesh.go +++ b/pkg/mesh/mesh.go @@ -82,7 +82,7 @@ type Node struct { Leader bool Location string Name string - PersistentKeepAlive int + PersistentKeepalive int Subnet *net.IPNet WireGuardIP *net.IPNet } diff --git a/pkg/mesh/topology.go b/pkg/mesh/topology.go index e237745..3c98bf5 100644 --- a/pkg/mesh/topology.go +++ b/pkg/mesh/topology.go @@ -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) }