From 59b2b8be8d6c4fbf153053d81294076f21da185e Mon Sep 17 00:00:00 2001 From: Anna Tikhonova Date: Wed, 7 Aug 2024 12:57:07 +0300 Subject: [PATCH] Use encoded (raw) URL paths Our kafka entities (e.g. consumer group names) contain unsafe symbols, such as forward slash and colon. This change forces Burrow (httprouter) to use encoded paths in URLs (Burrow plugin for Telegraf has always used PathEscape from "net/url" to form Burrow URLs). With raw path support, we do not loose metrics for groups with unsafe symbols in name. Original pull request to support raw path in httprouter: https://github.com/julienschmidt/httprouter/pull/209, waiting for merge since 2017. Looks like httprouter was abandoned around 2019. The author switched to their own fork: https://github.com/gravitational/teleport/pull/12109. Let's do the same. --- core/internal/httpserver/coordinator.go | 1 + go.mod | 2 ++ go.sum | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/internal/httpserver/coordinator.go b/core/internal/httpserver/coordinator.go index cfc4552a..6936e983 100644 --- a/core/internal/httpserver/coordinator.go +++ b/core/internal/httpserver/coordinator.go @@ -57,6 +57,7 @@ type Coordinator struct { func (hc *Coordinator) Configure() { hc.Log.Info("configuring") hc.router = httprouter.New() + hc.router.UseRawPath = true // If no HTTP server configured, add a default HTTP server that listens on a random port servers := viper.GetStringMap("httpserver") diff --git a/go.mod b/go.mod index 5c8ae57a..a3a0895c 100644 --- a/go.mod +++ b/go.mod @@ -68,3 +68,5 @@ require ( gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace github.com/julienschmidt/httprouter => github.com/gravitational/httprouter v1.3.1-0.20220408074523-c876c5e705a5 diff --git a/go.sum b/go.sum index 99852baf..4e390fcb 100644 --- a/go.sum +++ b/go.sum @@ -31,6 +31,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= +github.com/gravitational/httprouter v1.3.1-0.20220408074523-c876c5e705a5 h1:qg8FcGwRACSHortU1UxCSo9nF0t34rPWjk9Nef3j2Ic= +github.com/gravitational/httprouter v1.3.1-0.20220408074523-c876c5e705a5/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -53,8 +55,6 @@ github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh6 github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs= github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY= github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= -github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/karrick/goswarm v1.10.0 h1:hGUt7r6O3bR02whvkW/E4rU6Ei7MekGGlTD5zqAYSHo= github.com/karrick/goswarm v1.10.0/go.mod h1:wqange6Y/RHXs23gBc4nRXPent8RaiFyfl2+otwXj8U= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=