Skip to content

Commit

Permalink
Document changes for new env var
Browse files Browse the repository at this point in the history
  • Loading branch information
heschlie committed Jul 18, 2017
1 parent 1dbc0af commit 468b7bd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
23 changes: 15 additions & 8 deletions calico_node/startup/startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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)
}
Expand All @@ -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.
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion calico_node/tests/st/bgp/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion calico_node/tests/st/bgp/test_ipip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
6 changes: 3 additions & 3 deletions calico_node/tests/st/bgp/test_route_reflector_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion calico_node/tests/st/bgp/test_single_route_reflector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions master/reference/node/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down

0 comments on commit 468b7bd

Please sign in to comment.