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

Master-host IP is not overrided by environment variable. #1424

Closed
bat79a opened this issue Jun 12, 2020 · 9 comments
Closed

Master-host IP is not overrided by environment variable. #1424

bat79a opened this issue Jun 12, 2020 · 9 comments
Labels

Comments

@bat79a
Copy link

bat79a commented Jun 12, 2020

#899 # Describe the bug

When you try to override the --master-host ip with an environnement variable (k8s configMap) the ip is not use by the worker.

I have try this two variables without any effect :

  • LOCUST_MASTER_HOST
  • MASTER_HOST

Expected behavior

The worker will use the environment variable and the master will see this worker.

Actual behavior

  • If I use the command worker --master-host=my_ip the master can see my worker.
  • If I try to set the --master-host with my environment variable, the master can't see my worker.

Steps to reproduce

Environment

  • OS: Docker/K8S with environment variable in a ConfigMap
  • Python version: 3.6.1
  • Locust version: 1.0.3
  • Locust command line that you ran: ["locust", "-f", "locustfile.py", "--worker"]
  • Locust file contents (anonymized if necessary): /
@bat79a bat79a added the bug label Jun 12, 2020
@cyberw
Copy link
Collaborator

cyberw commented Jun 12, 2020

The env var name is LOCUST_MASTER_NODE_HOST, see https://docs.locust.io/en/stable/configuration.html#all-available-configuration-options

This was introduced to work around a common issue where people got collisions with the LOCUST_MASTER_PORT being set by kubernetes, see #1226

That workaround (non-standard env var name) is a little ugly tbh...

@bat79a
Copy link
Author

bat79a commented Jun 15, 2020

Hello.

I have checked the doc here : https://docs.locust.io/en/stable/configuration.html#environment-variables

But I saw 'example :' without any example, so I was thinking that the doc is not up to date and don't scroll after that point ;p
My bad.

I just tried the variable and everything works fine ;p
Thx a lot and sorry for my issue.

@bat79a bat79a closed this as completed Jun 15, 2020
@cyberw
Copy link
Collaborator

cyberw commented Jun 15, 2020

No worries @bat79a , this was a good issue! I'm trying to fix the documentation now...

@heyman I think we should consider not using custom env var names, as it violates the principle of least surprise (as shown by this ticket), but instead detecting and throwing a nice descriptive error for how to work around #1226.

@bat79a
Copy link
Author

bat79a commented Jun 15, 2020

@cyberw

Here i'ts why I have tried the MASTER_HOST variable for overriding the value.
this doc : https://docs.locust.io/en/stable/configuration.html#environment-variables

Extract :
--master-host MASTER_HOST
Host or IP address of locust master for distributed
load testing. Only used when running with --worker.
Defaults to 127.0.0.1.

PS : I tried to put a domain name and not an ip and it doesn't seem to work. Can we enter a domaine name instead of the ip ?

  • My use case is because I have deployed on a cloud provider, where each app is in a separate VM, so I can call the master from the worker only by a domain name.
  • Other use case is : in an other stack with kubernetes my master can change his ip when he reboot or change to an other node, so I can't know the ip of the master.

Thx a lot for you answer and your job ;p

@cyberw
Copy link
Collaborator

cyberw commented Jun 15, 2020

The documentation issue is fixed now (the invisible code block is there now): https://docs.locust.io/en/latest/configuration.html#environment-variables

Domain names should work, maybe dns resolution is not configured properly?

@heyman
Copy link
Member

heyman commented Jun 17, 2020

I think we should consider not using custom env var names, as it violates the principle of least surprise (as shown by this ticket), but instead detecting and throwing a nice descriptive error for how to work around #1226.

I've now fixed (ca8ef51) the help text which I believe was what source of confusion in this issue:

...
  --master-host MASTER_NODE_HOST
                        Host or IP address of locust master for distributed load testing. Only used when running with --worker. Defaults to 127.0.0.1.
  --master-port MASTER_NODE_PORT
                        The port to connect to that is used by the locust master for distributed load testing. Only used when running with --worker. Defaults to 5557.
...

I think it's much more likely that people to run into the issue of env var collisions when running locust on Kubernetes, than people running into issues because they guess the env var to be LOCUST_MASTER_HOST from the --master-host option (though I can see why it would happen before the metavar fix, like in this issue).

@bat79a
Copy link
Author

bat79a commented Jun 18, 2020

Hello @cyberw

The documentation issue is fixed now (the invisible code block is there now): https://docs.locust.io/en/latest/configuration.html#environment-variables

Domain names should work, maybe dns resolution is not configured properly?

I'm so sorry but impossible to put a domain name and make the worker visible for the master...

I have tried on my kubernetes cluster:

  LOCUST_MASTER_NODE_HOST: "locustio-master"

with my master internal name is :  
metadata:
  name: locustio-master
  LOCUST_MASTER_NODE_HOST: "locustio-master"
  LOCUST_MASTER_NODE_PORT: "5557"

Expose the service on my domaine name (wildcard where all the other services works perfectly)

  LOCUST_MASTER_NODE_HOST: "locust-api.dev.my_domaine.fr"
  LOCUST_MASTER_NODE_PORT: "80" because is exposed by the 80

It works only with the internal pod endpoint ip ?

Thx a lot.

@heyman
Copy link
Member

heyman commented Jun 18, 2020

@bat79a If it works with the IP it sounds like some kind of DNS issue, and I'm guessing that this is caused by some issue with your environment. Can you ping the master hostname from within a worker container?

@bat79a
Copy link
Author

bat79a commented Jun 18, 2020

@heyman GG, I forgot to open the container port 5557 in my yml manifest ;p

Thx a lot to all.

Have a nice day.

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