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

panic in logging http middleware #3921

Closed
brancz opened this issue Mar 12, 2021 · 0 comments · Fixed by #3922
Closed

panic in logging http middleware #3921

brancz opened this issue Mar 12, 2021 · 0 comments · Fixed by #3922

Comments

@brancz
Copy link
Member

brancz commented Mar 12, 2021

Thanos, Prometheus and Golang version used: main-2021-03-11-b2474aa3

Object Storage Provider: GCS

What happened:

Panic in the http logging middleware when querying

What you expected to happen:

No panic :)

How to reproduce it (as minimally and precisely as possible): I'm not certain but I think my requests don't have a Host header, so this panics:

port := strings.Split(r.Host, ":")[1]

Full logs to relevant components:

2021/03/12 09:56:26 http: panic serving 10.0.7.7:43392: runtime error: index out of range [1] with length 1                                                                                                                                   
goroutine 13538 [running]:                                                                                                                                                                                                                    
net/http.(*conn).serve.func1(0xc00037cdc0)                                                                                                                                                                                                    
        /usr/local/go/src/net/http/server.go:1801 +0x147                                                                                                                                                                                      
panic(0x1a9fbe0, 0xc00035fc40)                                                                                                                                                                                                                
        /usr/local/go/src/runtime/panic.go:975 +0x47a                                                                                                                                                                                         
github.com/thanos-io/thanos/pkg/logging.(*HTTPServerMiddleware).HTTPMiddleware.func1(0x7fb741825850, 0xc00007af50, 0xc0004a6c00)                                                                                                              
        /home/circleci/project/pkg/logging/http.go:42 +0x3ef                                                                                                                                                                                  
net/http.HandlerFunc.ServeHTTP(0xc00038f9e0, 0x7fb741825850, 0xc00007af50, 0xc0004a6c00)                                                                                                                                                      
        /usr/local/go/src/net/http/server.go:2042 +0x44                                                                                                                                                                                       
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerResponseSize.func1(0x7fb741825850, 0xc00007af00, 0xc0004a6c00)                                                                                                       
        /home/circleci/go/pkg/mod/github.com/prometheus/client_golang@v1.9.0/prometheus/promhttp/instrument_server.go:198 +0xe9                                                                                                               
net/http.HandlerFunc.ServeHTTP(0xc00038fda0, 0x7fb741825850, 0xc00007af00, 0xc0004a6c00)                                                                                                                                                      
        /usr/local/go/src/net/http/server.go:2042 +0x44                                                                                                                                                                                       
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerCounter.func1(0x7fb741825850, 0xc00007aeb0, 0xc0004a6c00)                                                                                                            
        /home/circleci/go/pkg/mod/github.com/prometheus/client_golang@v1.9.0/prometheus/promhttp/instrument_server.go:101 +0xda                                                                                                               
net/http.HandlerFunc.ServeHTTP(0xc000156060, 0x7fb741825850, 0xc00007aeb0, 0xc0004a6c00)                                                                                                                                                      
        /usr/local/go/src/net/http/server.go:2042 +0x44                                                                                                                                                                                       
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerRequestSize.func1(0x7fb741825850, 0xc00007adc0, 0xc0004a6c00)                                                                                                        
        /home/circleci/go/pkg/mod/github.com/prometheus/client_golang@v1.9.0/prometheus/promhttp/instrument_server.go:165 +0xe9                                                                                                               
net/http.HandlerFunc.ServeHTTP(0xc000156570, 0x7fb741825850, 0xc00007adc0, 0xc0004a6c00)                                                                                                                                                      
        /usr/local/go/src/net/http/server.go:2042 +0x44                                                                                                                                                                                       
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerDuration.func1(0x1e27300, 0xc000122380, 0xc0004a6c00)                                                                                                                
        /home/circleci/go/pkg/mod/github.com/prometheus/client_golang@v1.9.0/prometheus/promhttp/instrument_server.go:68 +0x11c                                                                                                               
net/http.HandlerFunc.ServeHTTP(...)                                                                                                                                                                                                           
        /usr/local/go/src/net/http/server.go:2042                                                                                                                                                                                             
main.runQueryFrontend.func1.1(0x1e27300, 0xc000122380, 0xc0004a6b00)                                                                                                                                                                          
        /home/circleci/project/cmd/thanos/query_frontend.go:238 +0x365                                                                                                                                                                        
net/http.HandlerFunc.ServeHTTP(0xc00021f3b0, 0x1e27300, 0xc000122380, 0xc0004a6b00)                                                                                                                                                           
        /usr/local/go/src/net/http/server.go:2042 +0x44                                                                                                                                                                                       
net/http.(*ServeMux).ServeHTTP(0xc0002dedc0, 0x1e27300, 0xc000122380, 0xc0004a6b00)                                                                                                                                                           
        /usr/local/go/src/net/http/server.go:2417 +0x1ad                                                                                                                                                                                      
net/http.serverHandler.ServeHTTP(0xc00003a2a0, 0x1e27300, 0xc000122380, 0xc0004a6b00)                                                                                                                                                         
        /usr/local/go/src/net/http/server.go:2843 +0xa3                                                                                                                                                                                       
net/http.(*conn).serve(0xc00037cdc0, 0x1e2ea00, 0xc000398280)                                                                                                                                                                                 
        /usr/local/go/src/net/http/server.go:1925 +0x8ad                                                                                                                                                                                      
created by net/http.(*Server).Serve                                                                                                                                                                                                           
        /usr/local/go/src/net/http/server.go:2969 +0x36c

@thanos-io/thanos-maintainers

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

Successfully merging a pull request may close this issue.

1 participant