From 468b7bde3cff492fb82bf43000596aeec03178b1 Mon Sep 17 00:00:00 2001 From: heschlie Date: Fri, 14 Jul 2017 15:51:28 -0700 Subject: [PATCH] Document changes for new env var --- calico_node/startup/startup.go | 23 ++++++++++++------- calico_node/tests/st/bgp/test_backends.py | 2 +- calico_node/tests/st/bgp/test_ipip.py | 2 +- .../st/bgp/test_route_reflector_cluster.py | 6 ++--- .../st/bgp/test_single_route_reflector.py | 2 +- master/reference/node/configuration.md | 1 + 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/calico_node/startup/startup.go b/calico_node/startup/startup.go index f99b7fa36e7..22fb4b8495b 100644 --- a/calico_node/startup/startup.go +++ b/calico_node/startup/startup.go @@ -248,6 +248,9 @@ func configureIPsAndSubnets(node *api.Node) bool { node.Spec.BGP = &api.NodeBGPSpec{} } + oldIpv4 := node.Spec.BGP.IPv4Address + oldIpv6 := node.Spec.BGP.IPv6Address + // This flag will let us know if we need to check conflicts when we see our // IP address (v4 or v6) change. checkConflicts := false @@ -265,9 +268,6 @@ func configureIPsAndSubnets(node *api.Node) bool { if cidr != nil { // We autodetected an IPv4 address, if we have no previous IP, or it is different than the previous IP, // we need to update it and check for conflicts. - if node.Spec.BGP.IPv4Address == nil || !node.Spec.BGP.IPv4Address.IP.Equal(cidr.IP) { - checkConflicts = true - } node.Spec.BGP.IPv4Address = cidr } else if node.Spec.BGP.IPv4Address == nil { // No IPv4 address is configured, but we always require one, so exit. @@ -285,7 +285,8 @@ func configureIPsAndSubnets(node *api.Node) bool { } } else { if ipv4Env != "" { - node.Spec.BGP.IPv4Address = parseIPEnvironment("IP", ipv4Env, 4) + envIp := parseIPEnvironment("IP", ipv4Env, 4) + node.Spec.BGP.IPv4Address = envIp } validateIP(node.Spec.BGP.IPv4Address) } @@ -297,9 +298,6 @@ func configureIPsAndSubnets(node *api.Node) bool { if cidr != nil { // We autodetected an IPv6 address, if we have no previous IP, or it is different than the previous IP, // we need to update it and check for conflicts. - if node.Spec.BGP.IPv6Address == nil || !node.Spec.BGP.IPv6Address.IP.Equal(cidr.IP) { - checkConflicts = true - } node.Spec.BGP.IPv6Address = cidr } else if node.Spec.BGP.IPv6Address == nil { // No IPv6 address is configured, but we have requested one, so exit. @@ -318,11 +316,20 @@ func configureIPsAndSubnets(node *api.Node) bool { } } else { if ipv6Env != "" { - node.Spec.BGP.IPv6Address = parseIPEnvironment("IP6", ipv6Env, 6) + envIp6 := parseIPEnvironment("IP6", ipv6Env, 6) + node.Spec.BGP.IPv6Address = envIp6 } validateIP(node.Spec.BGP.IPv6Address) } + // Detect if we've seen the IP address change, and flag that we need to check for conflicting Nodes + if oldIpv4 == nil || !node.Spec.BGP.IPv4Address.IP.Equal(oldIpv4.IP) { + checkConflicts = true + } + if oldIpv6 == nil || !node.Spec.BGP.IPv6Address.IP.Equal(oldIpv6.IP) { + checkConflicts = true + } + return checkConflicts } diff --git a/calico_node/tests/st/bgp/test_backends.py b/calico_node/tests/st/bgp/test_backends.py index a03dc3e76ec..589e8959a89 100644 --- a/calico_node/tests/st/bgp/test_backends.py +++ b/calico_node/tests/st/bgp/test_backends.py @@ -56,7 +56,7 @@ def test_bgp_backends(self): workload_host3 = host3.create_workload("workload3", network=network1, ip=DEFAULT_IPV4_ADDR_3) # Allow network to converge - self.assert_true(workload_host1.check_can_ping(workload_host2.ip, retries=10)) + self.assert_true(workload_host1.check_can_ping(workload_host2.ip, retries=15)) # Check connectivity in both directions self.assert_ip_connectivity(workload_list=[workload_host1, diff --git a/calico_node/tests/st/bgp/test_ipip.py b/calico_node/tests/st/bgp/test_ipip.py index fb0f680e4c6..4fec70a7184 100644 --- a/calico_node/tests/st/bgp/test_ipip.py +++ b/calico_node/tests/st/bgp/test_ipip.py @@ -281,7 +281,7 @@ def check(): assert self.get_tunl_tx(host1) == orig_tx + 2 else: assert self.get_tunl_tx(host1) == orig_tx - retry_until_success(check) + retry_until_success(check, retries=15) def get_tunl_tx(self, host): """ diff --git a/calico_node/tests/st/bgp/test_route_reflector_cluster.py b/calico_node/tests/st/bgp/test_route_reflector_cluster.py index 92a18bcf224..0bdf987f4c2 100644 --- a/calico_node/tests/st/bgp/test_route_reflector_cluster.py +++ b/calico_node/tests/st/bgp/test_route_reflector_cluster.py @@ -65,9 +65,9 @@ def _test_route_reflector_cluster(self, backend='bird'): create_bgp_peer(host, "node", rr.ip, 64513) # Allow network to converge (which it now will). - self.assert_true(workload_host1.check_can_ping(workload_host2.ip, retries=10)) - self.assert_true(workload_host1.check_can_ping(workload_host3.ip, retries=10)) - self.assert_true(workload_host2.check_can_ping(workload_host3.ip, retries=10)) + self.assert_true(workload_host1.check_can_ping(workload_host2.ip, retries=15)) + self.assert_true(workload_host1.check_can_ping(workload_host3.ip, retries=15)) + self.assert_true(workload_host2.check_can_ping(workload_host3.ip, retries=15)) # And check connectivity in both directions. self.assert_ip_connectivity(workload_list=[workload_host1, diff --git a/calico_node/tests/st/bgp/test_single_route_reflector.py b/calico_node/tests/st/bgp/test_single_route_reflector.py index 214f621faba..b8f2a377873 100644 --- a/calico_node/tests/st/bgp/test_single_route_reflector.py +++ b/calico_node/tests/st/bgp/test_single_route_reflector.py @@ -61,7 +61,7 @@ def _test_single_route_reflector(self, backend='bird'): create_bgp_peer(host1, "global", rg[0].ip, 64514) # Allow network to converge (which it now will). - self.assert_true(workload_host1.check_can_ping(workload_host2.ip, retries=10)) + self.assert_true(workload_host1.check_can_ping(workload_host2.ip, retries=15)) # And check connectivity in both directions. self.assert_ip_connectivity(workload_list=[workload_host1, diff --git a/master/reference/node/configuration.md b/master/reference/node/configuration.md index cfe9d4704a7..7529858cb77 100644 --- a/master/reference/node/configuration.md +++ b/master/reference/node/configuration.md @@ -16,6 +16,7 @@ The `calico/node` container is primarily configured through environment variable | IP6 | The IPv6 address for Calico will bind to. When specified, the address is saved in the [node resource configuration]({{site.baseurl}}/{{page.version}}/reference/calicoctl/resources/node) for this host, overriding any previously configured value. When omitted, if an address has not yet been configured in the node resource, IPv6 routing is not enabled. When omitted, if an IPv6 address has been previously configured in the node resource, IPv6 is enabled using the already configured address. | IPv6 | | | IP_AUTODETECTION_METHOD| The method to use to autodetect the IPv4 address for this host. This is only used when the IPv4 address is being autodetected. See [IP Autodetection methods](#ip-autodetection-methods) for details of the valid methods. | string | first-found | | IP6_AUTODETECTION_METHOD| The method to use to autodetect the IPv6 address for this host. This is only used when the IPv6 address is being autodetected. See [IP Autodetection methods](#ip-autodetection-methods) for details of the valid methods. | string | first-found | +| DISABLE_NODE_IP_CHECK| Skips checks for duplicate Node IPs. This can reduce the load on the cluster when a large number of Nodes are restarting. | string | false | | AS | The AS number for this node. When specified, the value is saved in the node resource configuration for this host, overriding any previously configured value. When omitted, if an AS number has been previously configured in the node resource, that AS number is used for the peering. When omitted, if an AS number has not yet been configured in the node resource, the node will use the global value (managed through `calicoctl config set/get asnumber`). | int | | | DATASTORE_TYPE | Type of datastore. | kubernetes, etcdv2 | etcdv2 | | WAIT_FOR_DATASTORE | Wait for connection to datastore before starting. If a successful connection is not made, node will shutdown. | boolean | false |