fix: traefik priority loss, caddy directive order, openresty cache, k3s diagnostic

Traefik was setting an explicit priority equal to the path length, which is smaller than traefik's default priority (rule length) on the web container. Web's bare Host(...) rule has implicit priority ~40 while my explicit 7 lost the match, so /api/v0/Procfile always went to web. Dropping the explicit priority lets traefik use rule length, which already gives longest-prefix-wins because the route rule includes both Host and PathPrefix and so is always longer than web's bare Host(...). Caddy's route block was being preempted by web's bare reverse_proxy due to caddy's default directive order (reverse_proxy ~190, route ~210). Switching to handle, which terminates matched requests and isn't bypassed by reverse_proxy, makes /api/v0/* land on api instead of web's catch-all. Openresty T2 polls longer (60 retries) and dumps sidecar logs on failure so the upstream label-update cache delay can be reported. The k3s files dump kubectl get service/ingress/endpoints in T1 so the next CI run reveals whether the api Service has ports and whether the Ingress backend reference is correct.
This commit is contained in:
Jose Diaz-Gonzalez
2026-06-02 22:07:17 -04:00
parent 5dce07ca7e
commit 53066ec4ac
5 changed files with 36 additions and 7 deletions

View File

@@ -34,13 +34,16 @@ fn-caddy-route-labels() {
# The named matcher accepts both the bare prefix and the prefix-glob form
# so requests like /api/v0 and /api/v0/users/42 both match.
output="$output --label 'caddy.${matcher_name}.path=${route_path} ${route_path}/*'"
output="$output --label 'caddy.${route_index}_route=${matcher_name}'"
# Use handle (not route) so the directive terminates the matched request.
# Otherwise web's bare `reverse_proxy` (at default-order ~190) runs before
# this route block (~210) and catches everything including /api/v0/*.
output="$output --label 'caddy.${route_index}_handle=${matcher_name}'"
local sub_index=0
if [[ "$route_strip" == "1" ]]; then
output="$output --label 'caddy.${route_index}_route.${sub_index}_uri=strip_prefix ${route_path}'"
output="$output --label 'caddy.${route_index}_handle.${sub_index}_uri=strip_prefix ${route_path}'"
sub_index=$((sub_index + 1))
fi
output="$output --label \"caddy.${route_index}_route.${sub_index}_reverse_proxy={{upstreams ${route_port}}}\""
output="$output --label \"caddy.${route_index}_handle.${sub_index}_reverse_proxy={{upstreams ${route_port}}}\""
route_index=$((route_index + 1))
done < <(plugn trigger proxy-routes-list "$APP")