locustio / locust

Write scalable load tests in plain Python 🚗💨
https://locust.cloud
MIT License
25.06k stars 3k forks source link

--master-host only accepts ipv4 formatted strings #835

Closed ginonott closed 5 years ago

ginonott commented 6 years ago

Description of issue / feature request

When setting up a distributed setup via docker-compose, I'd like to set the master-host to the locust_master service name. However, it seems that non-ipv4 formatted strings cause an error and crashes the slave. This is an example of what I would like to do (but causes the slave to crash with a ZMQError):

services:
version: '2.1'
services:
  locust_master:
    build: .
    ports:
      - "8081:8081"
    volumes:
      - '.:/src'
    command:
      'locust'

  locust_workers:
    build: .
    command:
      'locust  --slave --master-host=locust_master'
    depends_on:
      - locust_master

Expected behavior

It connects to the host via it's alias'ed hostname.

Actual behavior

It crashes with a ZMQError

Environment settings (for bug reports)

Steps to reproduce (for bug reports)

Create a dockerfile with locust and then try to bring up a master / slave where --master-host is set to locust_master

ginonott commented 6 years ago

In case anyone else is also having this issue, the current work-around is to create a custom network and fix the locust_master ip address and set the slave's to use that fixed ipv4 address. Here is an example:

version: '2.1'
services:
  locust_master:
    build: .
    command:
      'locust'
    networks:
      locust_net:
        ipv4_address: 172.16.238.10

  locust_workers:
    build: .
    command:
      'locust --slave --master-host=172.16.238.10'
    depends_on:
      - locust_master
    networks:
      - locust_net

networks:
  locust_net:
    driver: bridge
    ipam:
      driver: default
      config:
      -
        subnet: 172.16.238.0/24
cgoldberg commented 6 years ago

it crashes with a ZMQError

please post the stacktrace with error

ginonott commented 6 years ago

Sorry for the delay. Here's the dump:

[2018-07-16 14:28:48,270] 68bb9eb87895/ERROR/stderr: Traceback (most recent call last):
[2018-07-16 14:28:48,271] 68bb9eb87895/ERROR/stderr: File "/opt/bb/bin/locust", line 11, in <module>
[2018-07-16 14:28:48,271] 68bb9eb87895/ERROR/stderr: 
[2018-07-16 14:28:48,272] 68bb9eb87895/ERROR/stderr: load_entry_point('locust==0.8', 'console_scripts', 'locust')()
[2018-07-16 14:28:48,272] 68bb9eb87895/ERROR/stderr: File "/opt/bb/lib/python2.7/site-packages/locust/main.py", line 473, in main
[2018-07-16 14:28:48,278] 68bb9eb87895/ERROR/stderr: 
[2018-07-16 14:28:48,279] 68bb9eb87895/ERROR/stderr: runners.locust_runner = SlaveLocustRunner(locust_classes, options)
[2018-07-16 14:28:48,279] 68bb9eb87895/ERROR/stderr: File "/opt/bb/lib/python2.7/site-packages/locust/runners.py", line 357, in __init__
[2018-07-16 14:28:48,281] 68bb9eb87895/ERROR/stderr: 
[2018-07-16 14:28:48,281] 68bb9eb87895/ERROR/stderr: self.client = rpc.Client(self.master_host, self.master_port)
[2018-07-16 14:28:48,282] 68bb9eb87895/ERROR/stderr: File "/opt/bb/lib/python2.7/site-packages/locust/rpc/zmqrpc.py", line 30, in __init__
[2018-07-16 14:28:48,283] 68bb9eb87895/ERROR/stderr: 
[2018-07-16 14:28:48,284] 68bb9eb87895/ERROR/stderr: self.receiver.connect("tcp://%s:%i" % (host, port+1))
[2018-07-16 14:28:48,284] 68bb9eb87895/ERROR/stderr: File "zmq/backend/cython/socket.pyx", line 580, in zmq.backend.cython.socket.Socket.connect
[2018-07-16 14:28:48,285] 68bb9eb87895/ERROR/stderr: File "zmq/backend/cython/checkrc.pxd", line 25, in zmq.backend.cython.checkrc._check_rc
[2018-07-16 14:28:48,285] 68bb9eb87895/ERROR/stderr: zmq.error
[2018-07-16 14:28:48,285] 68bb9eb87895/ERROR/stderr: .
[2018-07-16 14:28:48,286] 68bb9eb87895/ERROR/stderr: ZMQError
[2018-07-16 14:28:48,286] 68bb9eb87895/ERROR/stderr: :
[2018-07-16 14:28:48,286] 68bb9eb87895/ERROR/stderr: Invalid argument
[2018-07-16 14:28:48,286] 68bb9eb87895/ERROR/stderr: 

Here's the command used to run it: locust -f /src/locustfile.py ${LOCUSTS} --logfile /src/output/workers.out --slave --master-host=locust_master' where locust_master is the service name in docker-compose. I also confirmed that I can curl http://locust_master:8081 and see the HTML that the master serves from the worker docker container, so they are properly networked together.

kasturichavan commented 5 years ago

@cgoldberg @aldenpeterson-wf Is there no other way than hardcoding an ipaddress to get this working ? When we deploy this in kubernetes, hardcoding ipadress will be a pain.

cgoldberg commented 5 years ago

I think this was a zeromq bug.. try upgrading that.

cyberw commented 5 years ago

Closing this, if it was not a zeromq bug please reopen with a more descriptive title.