Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: random order register backend handler path #588

Open
wu0407 opened this issue Nov 8, 2021 · 1 comment
Open

BUG: random order register backend handler path #588

wu0407 opened this issue Nov 8, 2021 · 1 comment

Comments

@wu0407
Copy link
Contributor

wu0407 commented Nov 8, 2021

trickster version: 2.0.0-beta2 and main

The path /api/v1/query handled by diffrent handler when multi run trickster.

/api/v1/query handle by httpproxy:

 POST /api/v1/query?query=sum%28traefik_backend_requests_total%3Arate_2m%7Bcode%3D%22502%22%2C+backend%21%3D%22dashboard-k8scs1-online.xxx.com%2F%22%7D%29+by+%28backend%2C+cluster%29&step=15s&time=1635906330 HTTP/1.1
> Host: 127.0.0.1:8480
> User-Agent: curl/7.73.0
> Accept: */*
> Content-Type: application/json; charset=utf-8
> Content-Length: 0
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Connection: keep-alive
< Content-Type: application/json; charset=utf-8
< Date: Fri, 05 Nov 2021 12:03:52 GMT
< X-Server-Hostname: vmselect-victoria-metrics-k8s-stack-6
< X-Trickster-Result: engine=HTTPProxy; status=proxy-only
< Transfer-Encoding: chunked

running logs:

time=2021-11-05T08:48:49.159669704Z app=trickster level=debug event="default backend identified" name=default caller=routing/routing.go:93
time=2021-11-05T08:48:49.159728924Z app=trickster level=info event="application loaded from configuration" logLevel=debug caller=trickster/config.go:262 goArch=amd64 commitID=3ae970a4eab3faa3204b7329e7796a35b6fac54c goVersion=go1.16 buildTime=2021-04-22T21:49:06+0000 config=/etc/trickster/trickster.yaml pid=1 name=trickster version=2.0.0-beta2
time=2021-11-05T08:48:49.15977232Z app=trickster level=info event="connecting to redis" Endpoint=redis:6379 caller=cache/redis/redis.go:65 protocol=tcp
time=2021-11-05T08:48:49.179134852Z app=trickster level=debug event="default backend identified" name=default caller=routing/routing.go:93
time=2021-11-05T08:48:49.179185169Z app=trickster level=info event="registering route paths" backendProvider=prometheus upstreamHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 caller=routing/routing.go:170 backendName=default
time=2021-11-05T08:48:49.179223214Z app=trickster level=debug event="registering backend handler path" handlerName=proxycache backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/targets/metadata matchType=exact frontendHosts= caller=routing/routing.go:307 backendName=default path=/api/v1/targets/metadata-0000000001
time=2021-11-05T08:48:49.179278879Z app=trickster level=debug event="registering backend handler path" handlerName=proxycache backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/alertmanagers matchType=exact frontendHosts= caller=routing/routing.go:307 backendName=default path=/api/v1/alertmanagers-0000000001
time=2021-11-05T08:48:49.179307981Z app=trickster level=debug event="registering backend handler path" caller=routing/routing.go:307 backendName=default path=/api/v1/targets-0000000001 handlerName=proxycache backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/targets matchType=exact frontendHosts=
time=2021-11-05T08:48:49.179311046Z app=trickster level=debug event="registering backend handler path" backendName=default path=/api/v1/query_range-0000000101 handlerName=query_range backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/query_range matchType=exact frontendHosts= caller=routing/routing.go:307
time=2021-11-05T08:48:49.179333161Z app=trickster level=debug event="registering backend handler path" matchType=exact frontendHosts= caller=routing/routing.go:307 backendName=default path=/api/v1/labels-0000000101 handlerName=labels backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/labels
time=2021-11-05T08:48:49.179362657Z app=trickster level=debug event="registering backend handler path" backendName=default path=/api/v1/series-0000000101 handlerName=series backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/series matchType=exact frontendHosts= caller=routing/routing.go:307
time=2021-11-05T08:48:49.179404208Z app=trickster level=debug event="registering backend handler path" path=/api/v1/alerts-0000000001 handlerName=alerts backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/alerts matchType=exact frontendHosts= caller=routing/routing.go:307 backendName=default
time=2021-11-05T08:48:49.179411895Z app=trickster level=debug event="registering backend handler path" backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/label/ matchType=prefix frontendHosts= caller=routing/routing.go:307 backendName=default path=/api/v1/label/-0000000001 handlerName=labels
time=2021-11-05T08:48:49.179428035Z app=trickster level=debug event="registering backend handler path" backendName=default path=/api/v1/status-0000000001 handlerName=proxycache backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/status matchType=prefix frontendHosts= caller=routing/routing.go:307
time=2021-11-05T08:48:49.17944088Z app=trickster level=debug event="registering backend handler path" path=/api/v1/admin-1111111111 handlerName=admin backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/admin matchType=prefix frontendHosts= caller=routing/routing.go:307 backendName=default
time=2021-11-05T08:48:49.179514285Z app=trickster level=debug event="registering backend handler path" path=/api/v1/-0000000101 handlerName=proxy backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/ matchType=prefix frontendHosts= caller=routing/routing.go:307 backendName=default
time=2021-11-05T08:48:49.179514459Z app=trickster level=debug event="registering backend handler path" backendName=default path=/api/v1/query-0000000101 handlerName=query backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/query matchType=exact frontendHosts= caller=routing/routing.go:307
time=2021-11-05T08:48:49.179533202Z app=trickster level=debug event="registering backend handler path" path=/api/v1/rules-0000000001 handlerName=proxycache backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/rules matchType=exact frontendHosts= caller=routing/routing.go:307 backendName=default
time=2021-11-05T08:48:49.179556191Z app=trickster level=info event="registering default backend handler paths" backendName=default caller=routing/routing.go:385
time=2021-11-05T08:48:49.179534553Z app=trickster level=debug event="registering backend handler path" handlerName=proxy backendHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/ matchType=prefix frontendHosts= caller=routing/routing.go:307 backendName=default path=/-0000000101
time=2021-11-05T08:48:49.179558842Z app=trickster level=debug event="registering health handler path" path=/trickster/health/default backendName=default upstreamPath=/select/0/prometheus/api/v1/query upstreamVerb= caller=routing/routing.go:196
time=2021-11-05T08:48:49.1796447Z app=trickster level=debug event="registering default backend handler paths" handlerName=alerts matchType=exact caller=routing/routing.go:389 backendName=default path=/api/v1/alerts
time=2021-11-05T08:48:49.17964634Z app=trickster level=debug event="registering default backend handler paths" path=/api/v1/query_range handlerName=query_range matchType=exact caller=routing/routing.go:389 backendName=default
time=2021-11-05T08:48:49.179663664Z app=trickster level=debug event="registering default backend handler paths" backendName=default path=/api/v1/series handlerName=series matchType=exact caller=routing/routing.go:389
time=2021-11-05T08:48:49.179671911Z app=trickster level=debug event="registering default backend handler paths" backendName=default path=/api/v1/targets/metadata handlerName=proxycache matchType=exact caller=routing/routing.go:389
time=2021-11-05T08:48:49.179723704Z app=trickster level=debug event="registering default backend handler paths" backendName=default path=/api/v1/admin handlerName=admin matchType=prefix caller=routing/routing.go:389
time=2021-11-05T08:48:49.179746506Z app=trickster level=debug event="registering default backend handler paths" matchType=prefix caller=routing/routing.go:389 backendName=default path=/api/v1/label/ handlerName=labels
time=2021-11-05T08:48:49.179749658Z app=trickster level=debug event="registering default backend handler paths" caller=routing/routing.go:389 backendName=default path=/api/v1/labels handlerName=labels matchType=exact
time=2021-11-05T08:48:49.17975588Z app=trickster level=debug event="registering default backend handler paths" caller=routing/routing.go:389 backendName=default path=/api/v1/ handlerName=proxy matchType=prefix
time=2021-11-05T08:48:49.179770329Z app=trickster level=debug event="registering default backend handler paths" handlerName=proxycache matchType=exact caller=routing/routing.go:389 backendName=default path=/api/v1/targets
time=2021-11-05T08:48:49.179839162Z app=trickster level=debug event="registering default backend handler paths" backendName=default path=/api/v1/query handlerName=query matchType=exact caller=routing/routing.go:389
time=2021-11-05T08:48:49.179846136Z app=trickster level=debug event="registering default backend handler paths" path=/api/v1/rules handlerName=proxycache matchType=exact caller=routing/routing.go:389 backendName=default
time=2021-11-05T08:48:49.179842085Z app=trickster level=debug event="registering default backend handler paths" backendName=default path=/api/v1/query handlerName=query matchType=exact caller=routing/routing.go:389
time=2021-11-05T08:48:49.179846136Z app=trickster level=debug event="registering default backend handler paths" path=/api/
v1/rules handlerName=proxycache matchType=exact caller=routing/routing.go:389 backendName=default
time=2021-11-05T08:48:49.179842085Z app=trickster level=debug event="registering default backend handler paths" backendNam
e=default path=/ handlerName=proxy matchType=prefix caller=routing/routing.go:389
time=2021-11-05T08:48:49.179858573Z app=trickster level=debug event="registering default backend handler paths" backendName=default path=/api/v1/status handlerName=proxycache matchType=prefix caller=routing/routing.go:389
time=2021-11-05T08:48:49.179855165Z app=trickster level=debug event="registering default backend handler paths" backendName=default path=/api/v1/alertmanagers handlerName=proxycache matchType=exact caller=routing/routing.go:389
time=2021-11-05T08:48:49.179904855Z app=trickster level=info event="registering pprof /debug routes" routerName=reload caller=routing/routing.go:52
time=2021-11-05T08:48:49.179935544Z app=trickster level=info event="registering pprof /debug routes" routerName=metrics caller=routing/routing.go:52
time=2021-11-05T08:48:49.180061067Z app=trickster level=info event="http listener starting" name=httpListener port=8480 address= caller=proxy/listener/listener.go:192
time=2021-11-05T08:48:49.180099787Z app=trickster level=debug event="starting proxy listener" scheme=http address= port=8480 caller=proxy/listener/listener.go:143 connectionsLimit=0
time=2021-11-05T08:48:49.180135624Z app=trickster level=debug event="starting proxy listener" scheme=http address=127.0.0.1 port=8484 caller=proxy/listener/listener.go:143 connectionsLimit=0
time=2021-11-05T08:48:49.180157582Z app=trickster level=info event="http listener starting" caller=proxy/listener/listener.go:192 name=reloadListener port=8484 address=127.0.0.1
time=2021-11-05T08:48:49.180153162Z app=trickster level=debug event="starting proxy listener" address= port=8481 caller=proxy/listener/listener.go:143 connectionsLimit=0 scheme=http
time=2021-11-05T08:48:49.180158891Z app=trickster level=info event="http listener starting" name=metricsListener port=8481 address= caller=proxy/listener/listener.go:192

/api/v1/query handle by objectcache:

 POST /api/v1/query?query=sum%28traefik_backend_requests_total%3Arate_2m%7Bcode%3D%22502%22%2C+backend%21%3D%22dashboard-k8scs1-online.xxx.com%2F%22%7D%29+by+%28backend%2C+cluster%29&step=15s&time=1635906330 HTTP/1.1
> Host: 127.0.0.1:8480
> User-Agent: curl/7.73.0
> Accept: */*
> Content-Type: application/json; charset=utf-8
> Content-Length: 0
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Cache-Control: s-maxage=30
< Connection: keep-alive
< Content-Type: application/json; charset=utf-8
< Date: Fri, 05 Nov 2021 12:18:43 GMT
< X-Server-Hostname: vmselect-victoria-metrics-k8s-stack-1
< X-Trickster-Result: engine=ObjectProxyCache; status=kmiss
< Transfer-Encoding: chunked
<
{ [2807 bytes data]
* Connection #0 to host 127.0.0.1 left intact

running logs:

time=2021-11-02T06:44:11.622463615Z app=trickster caller=routing/routing.go:93 level=debug event="default origin identified" name=default
time=2021-11-02T06:44:11.622532303Z app=trickster caller=trickster/config.go:238 level=info event="application loaded from configuration" goVersion=go1.14.14 commitID=4595bd6a1ae1165ef497251ad85c646dadc8a925 config=/etc/trickster/trickster.conf version=1.1.5 goArch=amd64 buildTime=2021-02-04T17:58:04+0000 logLevel=debug pid=1 name=trickster
time=2021-11-02T06:44:11.62257415Z app=trickster caller=cache/redis/redis.go:65 level=info event="connecting to redis" protocol=tcp Endpoint=redis:6379
time=2021-11-02T06:44:11.638201603Z app=trickster caller=routing/routing.go:93 level=debug event="default origin identified" name=default
time=2021-11-02T06:44:11.638258582Z app=trickster caller=routing/routing.go:175 level=info event="registering route paths" upstreamHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 originName=default originType=prometheus
time=2021-11-02T06:44:11.638304161Z app=trickster caller=routing/routing.go:254 level=debug event="registering health handler path" upstreamVerb=GET path=/trickster/health/default originName=default upstreamPath=/api/v1/query
time=2021-11-02T06:44:11.638372225Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" handledPath=/default/api/v1/query_range matchType=exact frontendHosts= originName=default path=/api/v1/query_range-GET-POST handlerName=query_range originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481
time=2021-11-02T06:44:11.638463702Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/targets/metadata matchType=exact frontendHosts= originName=default path=/api/v1/targets/metadata-GET handlerName=proxycache
time=2021-11-02T06:44:11.638532751Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" path=/api/v1/alertmanagers-GET handlerName=proxycache originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/alertmanagers matchType=exact frontendHosts= originName=default
time=2021-11-02T06:44:11.638598397Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" frontendHosts= originName=default path=/api/v1/labels-GET-POST handlerName=proxycache originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/labels matchType=exact
time=2021-11-02T06:44:11.638660053Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" path=/api/v1/series-GET-POST handlerName=series originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/series matchType=exact frontendHosts= originName=default
time=2021-11-02T06:44:11.638726114Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/query matchType=exact frontendHosts= originName=default path=/api/v1/query-GET-POST handlerName=query
time=2021-11-02T06:44:11.638783718Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" handledPath=/default/api/v1/targets matchType=exact frontendHosts= originName=default path=/api/v1/targets-GET handlerName=proxycache originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481
time=2021-11-02T06:44:11.638830811Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" originName=default path=/api/v1/status-GET handlerName=proxycache originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/status matchType=prefix frontendHosts=
time=2021-11-02T06:44:11.638856347Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/alerts matchType=exact frontendHosts= originName=default path=/api/v1/alerts-GET handlerName=proxycache
time=2021-11-02T06:44:11.638888503Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" originName=default path=/api/v1/label/-GET handlerName=proxycache originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/label/ matchType=prefix frontendHosts=
time=2021-11-02T06:44:11.638916399Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" path=/api/v1/-GET-POST handlerName=proxy originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/ matchType=prefix frontendHosts= originName=default
time=2021-11-02T06:44:11.638941349Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" matchType=exact frontendHosts= originName=default path=/api/v1/rules-GET handlerName=proxycache originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/api/v1/rules
time=2021-11-02T06:44:11.638976591Z app=trickster caller=routing/routing.go:318 level=debug event="registering origin handler path" originName=default path=/-GET-POST handlerName=proxy originHost=vmselect-victoria-metrics-k8s-stack.victoria.svc:8481 handledPath=/default/ matchType=prefix frontendHosts=
time=2021-11-02T06:44:11.638996791Z app=trickster caller=routing/routing.go:356 level=info event="registering default origin handler paths" originName=default
time=2021-11-02T06:44:11.639006533Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" path=/api/v1/query_range handlerName=query_range matchType=exact originName=default
time=2021-11-02T06:44:11.639036966Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" handlerName=proxycache matchType=exact originName=default path=/api/v1/targets/metadata
time=2021-11-02T06:44:11.639072964Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" handlerName=proxycache matchType=exact originName=default path=/api/v1/alertmanagers
time=2021-11-02T06:44:11.639103305Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" originName=default path=/api/v1/labels handlerName=proxycache matchType=exact
time=2021-11-02T06:44:11.639132694Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" handlerName=series matchType=exact originName=default path=/api/v1/series
time=2021-11-02T06:44:11.639163396Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" originName=default path=/api/v1/query handlerName=query matchType=exact
time=2021-11-02T06:44:11.639190598Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" matchType=exact originName=default path=/api/v1/targets handlerName=proxycache
time=2021-11-02T06:44:11.639228614Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" originName=default path=/api/v1/status handlerName=proxycache matchType=prefix
time=2021-11-02T06:44:11.639269142Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" originName=default path=/api/v1/alerts handlerName=proxycache matchType=exact
time=2021-11-02T06:44:11.63930939Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" originName=default path=/api/v1/label/ handlerName=proxycache matchType=prefix
time=2021-11-02T06:44:11.63934233Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" originName=default path=/api/v1/ handlerName=proxy matchType=prefix
time=2021-11-02T06:44:11.639387905Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" matchType=exact originName=default path=/api/v1/rules handlerName=proxycache
time=2021-11-02T06:44:11.639419246Z app=trickster caller=routing/routing.go:360 level=debug event="registering default origin handler paths" originName=default path=/ handlerName=proxy matchType=prefix
time=2021-11-02T06:44:11.639490743Z app=trickster caller=routing/routing.go:51 level=info event="registering pprof /debug routes" routerName=metrics
time=2021-11-02T06:44:11.639507948Z app=trickster caller=routing/routing.go:51 level=info event="registering pprof /debug routes" routerName=reload
time=2021-11-02T06:44:11.639679126Z app=trickster caller=proxy/listener/listener.go:144 level=debug event="starting proxy listener" connectionsLimit=0 scheme=http address=127.0.0.1 port=8484
time=2021-11-02T06:44:11.639699605Z app=trickster caller=proxy/listener/listener.go:192 level=info event="http listener starting" name=reloadListener port=8484 address=127.0.0.1
time=2021-11-02T06:44:11.639738377Z app=trickster caller=proxy/listener/listener.go:144 level=debug event="starting proxy listener" port=8481 connectionsLimit=0 scheme=http address=
time=2021-11-02T06:44:11.639753716Z app=trickster caller=proxy/listener/listener.go:192 level=info event="http listener starting" name=metricsListener port=8481 address=
time=2021-11-02T06:44:11.639787616Z app=trickster caller=proxy/listener/listener.go:144 level=debug event="starting proxy listener" address= port=8480 connectionsLimit=0 scheme=http
time=2021-11-02T06:44:11.639835641Z app=trickster caller=proxy/listener/listener.go:192 level=info event="http listener starting" name=httpListener port=8480 address=
@wu0407
Copy link
Contributor Author

wu0407 commented Nov 8, 2021

Why duplicate register default path handler in routing.RegisterProxyRoutes and routing.RegisterDefaultBackendRoutes?

o, err := routing.RegisterProxyRoutes(conf, router, mr, caches, tracers, logger, false)
if err != nil {
handleStartupIssue("route registration failed", tl.Pairs{"detail": err.Error()},
logger, errorFunc)
return err
}
if hc != nil {
hc.Shutdown()
}
hc, err = o.StartHealthChecks(logger)
if err != nil {
return err
}
alb.StartALBPools(o, hc.Statuses())
routing.RegisterDefaultBackendRoutes(router, o, logger, tracers)
routing.RegisterHealthHandler(mr, conf.Main.HealthHandlerPath, hc)
applyListenerConfigs(conf, oldConf, router, http.HandlerFunc(rh), mr, logger, tracers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant