[FLOC-3521] Support mapping public IP addresses in API client#2230
[FLOC-3521] Support mapping public IP addresses in API client#2230
Conversation
|
Why does this have to be done in the client at all? Why can't the caller do this? (The long term solution is completely ditching IPs from this API, I think). |
|
Because |
|
@jongiddy #2059 is an alternative option which would also be really useful for CoreOS deployments where the agents run in containers that have different IP addresses. (https://clusterhq.atlassian.net/browse/FLOC-2137) That's the way I was going to tackle this problem when I embarked on the benchmarking epic. If you still think this is the best way forward put this back up for review. |
|
@wallrj Yes, adding public IP address to I am planning some additional changes to the benchmarking code to make Itamar's suggestion more ergonomic, so I will close this PR. Thanks for your time. |
The
public_addressfield of Nodes returned form theflocker.apiclient.FlockerClientactually contains the internal cluster IP address, which can be a private IP address.Public IP addresses are very useful for clients using the API client module, but a node has no way of knowing which of its IP addresses is truly public, and in some cases, may not even know about a public IP address that routes to it (e.g. NAT addresses).
However, the code using
apiclientmay know the mapping, especially if it was somehow involved in starting the cluster. This is the case when a cluster is started usingrun-acceptance-testswhere the mapping from internal cluster hostnames to public IP addresses is exported as an environment variable.This PR allows the
apiclientuser, when creating aFlockerClient, to pass a mapping of internal hostname IP_ addresses to public IP addresses. Expand theNodeclass to include both the internal address, now as an additional field calledhostname(it's usual name in Flocker), and to setpublic_addressto the public IP address provided by a dictionary mapping hostname to public address.For Rackspace, the mapping provided by
run-acceptance-testsis{}which makes thehostnameandpublic_addressfields the same. This is appropriate since Rackspace IP addresses are public.For AWS,
run-acceptance-testsreturns a JSON structure{"10.0.0.1": "172.12.12.12"}which can be parsed into a Python dictionary for passing toFlockerClient.This will be used by the benchmarking code to SSH to individual cluster nodes to measure benchmark metrics.