locust: error: argument --master-port: invalid int value bug

Describe the bug

locust: error: argument --master-port: invalid int value: ‘tcp://172.30.44.4:8089’

Expected behavior

Locust runs correctly without producing this error. As --master-port wasn’t even supplied.

Actual behavior

When invoking locust in master mode using the following: locust -f /scripts/locust-script.py --master the following error occurs locust: error: argument --master-port: invalid int value: 'tcp://172.30.44.4:8089'

Steps to reproduce

Start locust in the container using the command: locust -f /scripts/locust-script.py --master Error occurs.

Environment settings

  • OS: RHEL
  • Python version: Python 3.6 from image registry.redhat.io/rhel8/python-36
  • Locust version: Using latest.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 53 (5 by maintainers)

Commits related to this issue

Most upvoted comments

This should not happen any more now that we have renamed the env var for master port to LOCUST_MASTER_NODE_PORT (the original issue I mean, some of the followup discussion here might still apply, but that should be a separate ticket)

ahh ok. i see what’s happening; it’s a clash between auto-populated ENV variables that come from creating “Service” objects in k8s. It only clicked now, but naming a Service “locust-master” in k8s results in an environment value that is “LOCUST_MASTER_SERVICE” (and a bunch of other values). And those auto names happen to overlap some of the names that locust looks at.

I’m not sure what the best solution is; documentation could help but that’s always fragile. Obviously short-term I can just just different names for the k8s objects.

Tried with LOCUST_MASTER_HOST and that is where slave is unable to connect master. it gets stuck here INFO/locust.main: Starting Locust 0.14.6. The master pod keeps waiting for the slave to connect.

Yeah I wouldn’t disable environment variable reading. Using environment variables is a standard (maybe even the standard) scenario in k8s.

I was more meaning that the warning/exception could know for certain that there is a k8s related issue if you see KUBERNETES_SERVICE_HOST and LOCUST_MASTER_PORT is a non-integer.

I’m agreeing with you 😃

Yeah I wouldn’t disable environment variable reading. Using environment variables is a standard (maybe even the standard) scenario in k8s.

I was more meaning that the warning/exception could know for certain that there is a k8s related issue if you see KUBERNETES_SERVICE_HOST and LOCUST_MASTER_PORT is a non-integer.

I’m actually seeing the same thing when trying to launch it in kubernetes. docker_start.sh is resulting in the following output, even if LOCUST_MODE is set to standalone

Starting Locust in standalone mode...
$ locust  --print-stats -f /locust/locustfile.py -H http://localhost
usage: locust [-h] [-H HOST] [--web-host WEB_HOST] [-P PORT] [-f LOCUSTFILE]
              [--csv CSVFILEBASE] [--csv-full-history] [--master] [--slave]
              [--master-host MASTER_HOST] [--master-port MASTER_PORT]
              [--master-bind-host MASTER_BIND_HOST]
              [--master-bind-port MASTER_BIND_PORT]
              [--heartbeat-liveness HEARTBEAT_LIVENESS]
              [--heartbeat-interval HEARTBEAT_INTERVAL]
              [--expect-slaves EXPECT_SLAVES] [--no-web] [-c NUM_CLIENTS]
              [-r HATCH_RATE] [-t RUN_TIME] [--skip-log-setup] [--step-load]
              [--step-clients STEP_CLIENTS] [--step-time STEP_TIME]
              [--loglevel LOGLEVEL] [--logfile LOGFILE] [--print-stats]
              [--only-summary] [--no-reset-stats] [--reset-stats] [-l]
              [--show-task-ratio] [--show-task-ratio-json] [-V]
              [--exit-code-on-error EXIT_CODE_ON_ERROR] [-s STOP_TIMEOUT]
              [LocustClass [LocustClass ...]]
locust: error: argument --master-port: invalid int value: 'tcp://10.96.24.182:5557'

If I launch a container with kubectl run, kubectl run shell --rm -i --tty --image locustio/locust:0.13.5 -- ash and then I can set environment variables and execute docker_start.sh and it’s fine