dockercloud-haproxy
dockercloud-haproxy copied to clipboard
EXTRA_ROUTE_SETTINGS is global for every server
Using following docker-compose.yml
version: '2'
services:
blue:
image: dockercloud/hello-world
environment:
- "EXTRA_ROUTE_SETTINGS=weight 1"
green:
image: dockercloud/hello-world
environment:
- "EXTRA_ROUTE_SETTINGS=weight 2"
lb:
image: dockercloud/haproxy
links:
- blue
- green
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 80
I may expect something like
backend default_service
server test_blue_1 test_blue_1:80 check inter 2000 rise 2 fall 3 weight 1
server test_green_1 test_green_1:80 check inter 2000 rise 2 fall 3 weight 2
but actual result is
backend default_service
server test_blue_1 test_blue_1:80 check inter 2000 rise 2 fall 3 weight 2
server test_green_1 test_green_1:80 check inter 2000 rise 2 fall 3 weight 2
@kakawait Looks like it is a bug. I will take a look at it.
Thank you for pointing it out :)
It's not just EXTRA_ROUTE_SETTINGS. Also for instance HEALTH_CHECK suffers from the same problem.
@hierynomus
True. The code is written under the assumption that all the routes in the same backend have the same route settings.
If you set VIRTUAL_HOST on each service, the routes are configured as expected. Without VIRTUAL_HOST, all the routes from all the services are put into the default_service backend, and the script simply pick one of the settings randomly and apply to all the routes.
Let me think how to solve the issue easily in your use case.
@tifayuki, Thanks. The main use-case I have is that I wanted to inject the backup keyword in the EXTRA_ROUTE_SETTINGS so that I can configure a hot-failover scenario.
@tifayuki I've submitted PR #120 which fixes my scenario at least. If you know can suggest a better way of fixing (or implementing) this, I'd be more than happy to take another stab at this.
if I set the same VIRTUAL_HOST for two services and specify EXTRA_ROUTE_SETTINGS for one of them, that setting will affect both. I want to use this to append "backup" to one of the services.
Unfortunately the solution in #120 does not work for me. I still get backup appended to both services.
@MicOestergaard, as per #120, you can add FAILOVER=true to the environment of the node to fix the backup route.
Unfortunately that doesn't work for me. Adding FAILOVER to the backup service results in all other services getting backup route as well.
@tifayuki I have submitted PR #222 which seems to fix the issue for me. Let me know if I have missed something and I'll take another look at it.