Resilient routing on invalid middlewares

We faced a problem when an existing router defined through an Ingress kubernetes resource is modified to add a routing middleware, if the reference to the middleware does not exist the routing will be marked as disabled and the routing will start returning 404 status code.

  • Is it possible to avoid this and keep existing configuration instead?
  • If there is no existing routing can be defined but just without that invalid/missing middleware?

Thanks in advance

To my knowledge, Traefik doesn’t keep or fall back to a previous valid config. When a router references a non-existent middleware, the configuration is considered invalid and the router is disabled, resulting in 404s.

Ignoring missing middlewares and keeping the route active isn’t supported and is probably avoided by design, since it could lead to unintended behavior. Imagine if the missing middleware is security-related: allowing the route to remain active without it could expose services without proper protection.

Thanks

Yes that was my understanding after reading the source code.

Our issue it was, we introduced a typo referencing a middleware which resulted on 404 until fixed.

Another scenario if I'm not wrong is adding another middleware to the chain. Until the middleware is created through CRD provider which is eventually consistent the ingress provider could disable the router until it exists.

We're thinking in a solution which at least solve or mitigate this issues.

  • 1st adding some linter could help.
  • 2nd using for example sync-wave as we use ArgoCD, but middleware CRs do not expose a status field so make checking if available a little bit complex.