Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPv4 and IPv6 selection compatibility between --local-ips and --dns #1733

Open
divfor opened this issue Nov 20, 2020 · 2 comments
Open

IPv4 and IPv6 selection compatibility between --local-ips and --dns #1733

divfor opened this issue Nov 20, 2020 · 2 comments
Labels

Comments

@divfor
Copy link
Contributor

divfor commented Nov 20, 2020

DNS new feature (--dns) has possible policy values are:

preferIPv4: use IPv4 addresses, if available, otherwise fall back to IPv6 (the new default value).
preferIPv6: use IPv6 addresses, if available, otherwise fall back to IPv4.
onlyIPv4: only use IPv4 addresses, ignore any IPv6 ones.
onlyIPv6: only use IPv6 addresses, ignore any IPv4 ones.
any: no preference, use all addresses (the old k6 behavior).

But Local-IPs feature (--local-ips) does not allow mixed usage of IPv4/IPv6, since each VU will be allocated one IPv4 or one IPv6 in the initialisation stage.
maybe we can allow this option to accept mixed ipv4/v6 ranges/cidrs to create a IPv4 IPPool and a IPv6 IPPool. Then each VU will be allocated one IPv4 and one IPv6 addresses, that will be picked respectively for sending requests to DNS-resolved destination IP address.

@divfor divfor added the bug label Nov 20, 2020
@na--
Copy link
Member

na-- commented Nov 20, 2020

Hmm I'm not sure if I'd consider this a quite a bug, it's more like something between a bug and missing functionality... In any case, it's a very valid point we should address. However, as I mentioned in #1682 (review), I don't think we should complicate the global --local-ips option further.

Instead, I think fixing this should fall under the aegis of #1724. I haven't thought exactly how that API should look like, but here's a quick preliminary example:

import http from 'k6/http';
import vu from 'k6/vu';

vu.setLocalIPv4('13.37.0.1');
vu.setLocalIPv6('2001:0db8:85a3:0000:0000:8a2e:0370:7334');

export default function () {
    http.get('https://test.k6.io/');
}

Of course, you could randomly generate the actual IPs or pick them from a list sequentially with __VU and modulo division, or randomly with Math.random(), so that each VU has a different source IP... You should even be able to change the API on every iteration, if you want to, or in the middle of one. I think this is the simplest way to implement the full feature (no over-complicated global options), the most flexible one (you can implement whatever IP picking scheme you want, weights, you can even change the source IP whenever), and the most user-friendly one (it's very apparent what's happening, no magic).

The proposed vu.setLocalIPv4() and vu.setLocalIPv6() functions (or however we decide to call them) would also be usable without setting --local-ips at all. If both --local-ips and these functions are used, the local-ips values would just serve as the available pool of valid values for the functions, so an exception is thrown if the functions are called with some IP outside of the the specified local-ips. But if no local-ips is specified, users should be able to pick any IP that is available on the machine without any restrictions.

@mstoykov
Copy link
Collaborator

Also mentioned here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants