Manipulating Loadbalancer via custom plugin

I'm trying to find a way to find a good way to disable servers based on the code version deployed to each server.

I'm using the ECS provider to discover services.

This is the process that I want:

  • A new task is deployed to ECS and discovered by Traefik.

  • A flag is flipped (in Redis or in a file), indicating that requests should be paused, for migrations.

  • All request are held onto by Traefik, but not routed to any servers yet.

  • Run database migrations.

  • Un-pause requests.

  • If the migrations are successful, all requests are directed to the server running the latest version.

  • If the migrations failed, all requests are directed to the server running the old version.

My idea is to create a plugin that either manipulates the WRR weight of the servers or sets the sticky session cookie (kinda hacky).

  1. Is there a way to define some metadata per "server" (not service)? It should be done with docker labels and needs to be readable by the plugin. This is so the plugin can know what version each server is running.

  2. How is the server name generated in the ECS Provider? (Is it generated in the ECS Provider?) Using some logging (with docker provider, I assume ECS behaves the same), I was able to find out the the server names seem to look like this: e3497c68de221f3b rather than http://172.20.0.5:80, which would be a lot easier to work with.