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

Decide if ipv6 can work #2923

Merged
merged 5 commits into from
Oct 11, 2024
Merged

Conversation

nc-marco
Copy link

@nc-marco nc-marco commented Oct 3, 2024

Summary of changes:

Previously IPV6 was enabled if the kernel supported the IPV6 stack.  This was an issue in the distributed scenario when there is a network component between the master and worker nodes that does not support IPV6.  This is the case for example in AWS EKS cluster where the service resource does not support IPV6 even if the pods in the cluster do.  
To avoid attempting to communicate over IPv6 when it is not possible, some basic logic was added  which does the following:

  1. Determine as before if the kernel supports IPv6, but uses the socket method, has_dualstack_ipv6().  This does not have the limitations of has_ipv6() of the socket library (and I imagine the reason why it was avoided) since it actually does a syscall to the kernel which will fail if the kernel does not support IPv6.  We chose to switch to this method (from that of urllib3) since we needed other methods from the basic python socket library.
  2. Verify if the master hostname can be resolved as an IPv6 address.  This was deemed as a reasonable way to determine if the network environment supports IPv6 (outside of the OS where locust is running).  No admin would configure AAAA DNS records if the network isn't completely IPv6 ready.
  3. If IP addresses are used instead of host names (for example in the bind on the server side), then determine if the address is a valid IPv6 address or not. 

The same checks are done independently on the server and client during socket creation and will require no changes in the use of locust.  For example, currently the bind address of '*' will cause the master node to listen on both IPv6 and IPv4 addresses.  This behaves the same as before while setting master_bind_host to an IPv4 address, such as '0.0.0.0', will prevent zmq from enabling IPv6 on the master since it should only listen on an IPv4 interface.

@cyberw
Copy link
Collaborator

cyberw commented Oct 9, 2024

Fix looks reasonable but we'd need to investigate what's wrong with macos/windows.

@nc-marco
Copy link
Author

nc-marco commented Oct 9, 2024 via email

@nc-marco
Copy link
Author

So, thanks to my friend's mac (I run linux of course), we were able to see what the issue was. It was raising and resolver error. I need to dig probably deeper to understand why it happens on macOS and windows and not Linux, but putting in a try/except block and now it passes on these OS's. I verified it still does what I want it to do in EKS, so I'm happy with it. I'll leave it up to you to decide if it is OK.

@cyberw
Copy link
Collaborator

cyberw commented Oct 11, 2024

I think it looks OK! Any specific reason you renamed the socked module?

import socket as csocket

@nc-marco
Copy link
Author

nc-marco commented Oct 11, 2024 via email

@cyberw
Copy link
Collaborator

cyberw commented Oct 11, 2024

maybe from socket import gaierror, has_dualstack_ipv6?

I dont really have a strong opinion either, but renames always rub me the wrong way :)

@nc-marco
Copy link
Author

nc-marco commented Oct 11, 2024 via email

@cyberw cyberw merged commit 4d12906 into locustio:master Oct 11, 2024
16 checks passed
@nc-marco
Copy link
Author

nc-marco commented Oct 11, 2024 via email

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

Successfully merging this pull request may close these issues.

2 participants