Add util function for getting IP address from gateway
- Dominant language
- Python
- Stars
- 7
- Forks
- 29
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 7
Description
Currently this pattern is used for extracting loadbalancer IP address or hostname from a gateway `gateway.external_ip().split(":")[0]`
Two problems:
1. the name `external_ip` is misleading as it can also be a hostname (on AWS clusters)
2. If it would return an IPv6 IP address this split would not work see example IPv6 address: `2001:0db8:85a3:0000:0000:8a2e:0370:7334` or with port `[2001:db8:4006:812::200e]:8080` (I do not know how Openshift loadbalanced service handles IPv6 addresses if those are even used at all)
Its used currently in multiple places in mutlicluster tests:
```
./testsuite/tests/multicluster/coredns/two_clusters/test_delegate_false.py:102: dns.resolver.resolve(hostname2.hostname)[0].address == gateway2.external_ip().split(":")[0]
./testsuite/tests/multicluster/coredns/two_clusters/test_delegate_false.py:105: gateway2.external_ip().split(":")[0] not in dns_ips
./testsuite/tests/multicluster/load_balanced/test_change_default_geo.py:21: assert resolver.resolve(hostname.hostname)[0].address == gateway.external_ip().split(":")[0]
./testsuite/tests/multicluster/load_balanced/test_change_default_geo.py:32: assert resolver.resolve(hostname.hostname)[0].address == gateway2.external_ip().split(":")[0]
./testsuite/tests/multicluster/load_balanced/test_change_strategy.py:17: assert resolver.resolve(hostname.hostname)[0].address == gateway.external_ip().split(":")[0]
./testsuite/tests/multicluster/load_balanced/test_change_strategy.py:20: assert resolver.resolve(hostname.hostname)[0].address == gateway2.external_ip().split(":")[0]
./testsuite/tests/multicluster/load_balanced/test_change_strategy.py:35: assert resolver.resolve(hostname.hostname)[0].address == gateway.external_ip().split(":")[0]
./testsuite/tests/multicluster/load_balanced/test_load_balanced_geo.py:21: assert resolver.resolve(hostname.hostname)[0].address == gateway.external_ip().split(":")[0]
./testsuite/tests/multicluster/load_balanced/test_load_balanced_geo.py:24: assert resolver.resolve(hostname.hostname)[0].address == gateway2.external_ip().split(":")[0]
./testsuite/tests/multicluster/load_balanced/test_load_balanced_geo.py:27: assert resolver.resolve(hostname.hostname)[0].address == gateway.external_ip().split(":")[0]
./testsuite/tests/multicluster/test_simple_strategy.py:26: gw1_ip, gw2_ip = gateway.external_ip().split(":")[0], gateway2.external_ip().split(":")[0]
```
## To solve this
An util function should be implemented to do the extraction correctly and/or method for extracting IP address from gateway be re-done that will solve the problems.
Contributor guide
Research direction
Start by locating the gateway.external_ip() implementation and reviewing the listed multicluster test usages, especially tests/multicluster/coredns/two_clusters/test_delegate_false.py and tests/multicluster/load_balanced/. Define the utility or gateway method around the existing IPv4, hostname, and IPv6 examples, replace the repeated split(":")[0] calls, and run the affected multicluster tests to confirm address comparisons still work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100