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

Get fetch timeout from db config #1342

Merged
merged 5 commits into from
Feb 1, 2019
Merged

Conversation

benraskin92
Copy link
Collaborator

No description provided.

@benraskin92 benraskin92 changed the title Get fetch timeout from db config [WIP] Get fetch timeout from db config Jan 31, 2019
@@ -131,8 +132,12 @@ func (h *Handler) RegisterRoutes() error {
).Methods(openapi.HTTPMethod)
h.router.PathPrefix(openapi.StaticURLPrefix).Handler(logged(openapi.StaticHandler()))

timeoutOpts := &prometheus.TimeoutOpts{
FetchTimeout: h.embeddedDbCfg.Client.FetchTimeout,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@r and @richardartoul are we guaranteed that embeddedDbCfg.Client != nil here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than having this, have the handler take in a TimeoutOpts in NewHandler and set it on the Handler stuct

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think its guaranteed to be set

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay maybe I'll just set it here then if it's nil

@codecov
Copy link

codecov bot commented Jan 31, 2019

Codecov Report

Merging #1342 into master will decrease coverage by 10.5%.
The diff coverage is 54.5%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1342      +/-   ##
=========================================
- Coverage    70.7%   60.2%   -10.6%     
=========================================
  Files         822     810      -12     
  Lines       70160   68630    -1530     
=========================================
- Hits        49643   41321    -8322     
- Misses      17293   24309    +7016     
+ Partials     3224    3000     -224
Flag Coverage Δ
#aggregator 81% <ø> (-1.4%) ⬇️
#cluster 62.9% <ø> (-22.7%) ⬇️
#collector 67.6% <ø> (-10.8%) ⬇️
#dbnode 74.7% <ø> (-6.1%) ⬇️
#m3em 57% <ø> (-16.2%) ⬇️
#m3ninx 52.8% <ø> (-21.5%) ⬇️
#m3nsch 79.1% <ø> (+27.9%) ⬆️
#metrics 17.8% <ø> (ø) ⬆️
#msg 74.9% <ø> (-0.2%) ⬇️
#query 40.8% <54.5%> (-23.5%) ⬇️
#x 66.3% <ø> (-9.9%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2aac099...ef469e6. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 31, 2019

Codecov Report

Merging #1342 into master will decrease coverage by <.1%.
The diff coverage is 76.9%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #1342     +/-   ##
========================================
- Coverage    70.7%   70.7%   -0.1%     
========================================
  Files         822     822             
  Lines       70192   70204     +12     
========================================
- Hits        49656   49637     -19     
- Misses      17309   17332     +23     
- Partials     3227    3235      +8
Flag Coverage Δ
#aggregator 82.3% <ø> (ø) ⬆️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.7% <ø> (-0.2%) ⬇️
#m3em 73.2% <ø> (ø) ⬆️
#m3ninx 74.2% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.8% <ø> (ø) ⬆️
#msg 75% <ø> (+0.1%) ⬆️
#query 64.2% <76.9%> (ø) ⬆️
#x 76.2% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7101751...8479181. Read the comment docs.

@robskillington robskillington changed the title [WIP] Get fetch timeout from db config Get fetch timeout from db config Jan 31, 2019
require.NoError(t, err)
h.embeddedDbCfg = &dbconfig.DBConfiguration{Client: client.Configuration{FetchTimeout: 15 * time.Second}}

return h, nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to return nil here, instead change the return to just be *Handler

@@ -46,6 +47,10 @@ import (

var (
promReadTestMetrics = newPromReadMetrics(tally.NewTestScope("", nil))

timeoutOpts = &prometheus.TimeoutOpts{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test to check that the timeout is being honoured?

Fix test

Fix tests

Address comments

Fix test
@benraskin92 benraskin92 force-pushed the braskin/timeout_config branch from 3f5aa0e to b59f733 Compare February 1, 2019 16:52
defaultTimeout = time.Second * 15
maxTimeout = 5 * time.Minute
// DefaultTimeout is the default timeout for fetch requests
DefaultTimeout = 15 * time.Second
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels a bit weird to export this from here; I think it would read better if you had this hardcoded backup value in src/query/api/v1/httpd/handler.go and keep it unexported.

Then in common_test hardcode the 15 seconds as the test value (might be better to up to 30 in light of user comments on gitter?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I went back and forth on this. I'll put in handler.go

req, _ := http.NewRequest("POST", PromReadURL, test.GeneratePromReadBody(t))
dur, err := prometheus.ParseRequestTimeout(req, promRead.timeoutOpts.FetchTimeout)
require.NoError(t, err)
assert.Equal(t, 2*time.Minute, dur)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Can you add a test with a default, and an invalid timeout value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have these tests in the native package. Not sure we need to duplicate.

@@ -64,17 +64,17 @@ func TestTimeoutParse(t *testing.T) {
req, _ := http.NewRequest("POST", "dummy", nil)
req.Header.Add("timeout", "1ms")

timeout, err := ParseRequestTimeout(req)
timeout, err := ParseRequestTimeout(req, time.Second)
assert.NoError(t, err)
assert.Equal(t, timeout, time.Millisecond)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this fail?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops never mind github hid the top bit

if embeddedDbCfg == nil {
timeoutOpts.FetchTimeout = defaultTimeout
} else {
if embeddedDbCfg.Client.FetchTimeout < 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick test to check this?

Copy link
Collaborator

@arnikola arnikola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, just one more test around setting default?

@benraskin92 benraskin92 merged commit 2cf0172 into master Feb 1, 2019
@justinjc justinjc deleted the braskin/timeout_config branch June 17, 2019 21:56
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 this pull request may close these issues.

3 participants