GitHub issue middleware-manager #113, opened by
strausmannon GitHub
Summary
When a Pangolin resource uses multi-target path-based routing (one host, multiple Targets each with a different PathPrefix, producing multiple Traefik routers that all share the same Host(...) in their rule), middleware-manager’s /api/v1/traefik-config endpoint returns a different priority value for the same router on different requests, even though the upstream Pangolin config is byte-identical between requests. This happens roughly once per 5-second cache cycle (matching ConfigProxy’s cacheDuration).
Because Traefik polls this endpoint continuously and rebuilds its router table on any content change, this causes:
- Constant, unnecessary router-table rebuilds (content changes every ~5s even when nothing changed upstream).
- A real routing bug: when the catch-all router’s priority is corrupted to match the more specific router’s priority, a priority tie between the two routers is possible, and Traefik’s tie-break can transiently route requests meant for the specific path to the catch-all router instead.
Root cause (source-verified against main @ 7eb1378d826ca203502332c61d14879bb1436f14 / v4.5.0)
services/config_proxy.go, function findMatchingRouter (~line 989):
func (cp *ConfigProxy) findMatchingRouter(routers map[string]interface{}, host string) (string, map[string]interface{}) {
...
for routerName, routerConfig := range routers { // unordered Go map iteration
...
if len(hostMatches) > 1 && …
---
💬 Discuss it here. Status, fixes and code review stay on [GitHub](https://github.com/hhftechnology/middleware-manager/issues/113).
<!-- hhf-forum-sync -->