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

feat(proxy) implement upstream timeouts #2036

Merged
merged 1 commit into from
Feb 2, 2017

Conversation

thibaultcha
Copy link
Member

@thibaultcha thibaultcha commented Feb 1, 2017

Summary

This implements timeout options between Kong and the upstream services/APIs. It adds 3 new fields to the API definition: upstream_connect_timeout, upstream_send_timeout, and upstream_read_timeout.

Those fields use a ms precision, and this take an integer value between 1 and 2^31 - 1.

When not specified, the default value is 60000 (60 seconds) for all 3 fields.

Full changelog

  • add new fields to APIs for connect/send/read timeouts
  • fields are in ms precision, and must be greater than 0

Copy link
Member

@Tieske Tieske left a comment

Choose a reason for hiding this comment

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

minor things, except the technical error message, that should go imo.

upstream_connect_timeout = 60000,
upstream_send_timeout = 60000,
upstream_read_timeout = 60000,
}, { id = row.id })
Copy link
Member

Choose a reason for hiding this comment

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

upstream_connect_timeout = 60000,
upstream_send_timeout = 60000,
upstream_read_timeout = 60000,
}, { id = row.id })
Copy link
Member

Choose a reason for hiding this comment

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

same, no need to hardcode


local function check_u_int(t)
if t < 1 or t > 2^31 - 1 or math.floor(t) ~= t then
return false, "must be an integer between 1 and 2^31 - 1"
Copy link
Member

Choose a reason for hiding this comment

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

error message to technical. And in general (matter of taste) I prefer this; https://github.com/Mashape/kong/blob/a6f0cb38661a09cd91802fbdd4ba8c1c696b17d0/kong/dao/schemas/upstreams.lua#L4-L6


ok, err = set_timeouts(addr.connect_timeout / 1000,
addr.send_timeout / 1000,
addr.read_timeout / 1000)
Copy link
Member

Choose a reason for hiding this comment

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

Can't we do these calculations at config-load time, instead of on each request? Should be an easy fix with the new caching (the way I intend to do it)

Copy link
Member

Choose a reason for hiding this comment

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

I mean the refactor of the cache scheduled for 0.11

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't we do these calculations at config-load time, instead of on each request?

I'd rather not. It'd be harder to track in case something goes wrong or if we start loading APIs from another place and forget to do the conversion, etc...

Should be an easy fix with the new caching (the way I intend to do it)

I think we should sync up on that, because the way I understood it, I was supposed to work on the new caching in 0.11? BTW, I cannot know which way you intend to do it if you do not elaborate.

@Tieske Tieske added pr/changes requested Changes were requested to this PR by a maintainer. Please address them and ping back once done. and removed pr/status/needs review labels Feb 2, 2017
@thibaultcha thibaultcha force-pushed the feat/upstream-timeouts branch from a6f0cb3 to 7327fbf Compare February 2, 2017 19:49
@thibaultcha thibaultcha removed the pr/changes requested Changes were requested to this PR by a maintainer. Please address them and ping back once done. label Feb 2, 2017
* add new fields to APIs for connect/send/read timeouts
* fields are in ms precision, and must be greater than 0
* update CHANGELOG.md with new feature
@thibaultcha thibaultcha force-pushed the feat/upstream-timeouts branch from 7327fbf to f8408c7 Compare February 2, 2017 19:52
@thibaultcha
Copy link
Member Author

@Tieske Thanks for the review!

@thibaultcha thibaultcha merged commit b422080 into release/0.10.0 Feb 2, 2017
@thibaultcha thibaultcha deleted the feat/upstream-timeouts branch February 2, 2017 19: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.

2 participants