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

plugin/cancel: add context cancelation plugin #2711

Merged
merged 3 commits into from
Mar 29, 2019
Merged

plugin/cancel: add context cancelation plugin #2711

merged 3 commits into from
Mar 29, 2019

Conversation

miekg
Copy link
Member

@miekg miekg commented Mar 22, 2019

Per review comments on #2704, move this into a plugin that gets called.
Add the most minimal plugin, tests and documenation.

Per review comments on #2704, move this into a plugin that gets called.
Add the most minimal plugin, tests and documenation.

Signed-off-by: Miek Gieben <miek@miek.nl>
@corbot corbot bot requested a review from stp-ip March 22, 2019 15:46
@corbot
Copy link

corbot bot commented Mar 22, 2019

Thank you for your contribution. I've just checked the OWNERS files to find a suitable reviewer. This search was successful and I've asked stp-ip (via /OWNERS) for a review.

If you have questions or suggestions for this bot, please file an issue against the miekg/dreck repository.

The bot understands the commands that are listed here.

The *cancel* plugin creates a canceling context for each request. It adds a timeout that gets
triggered after 5001 milliseconds.

The 5001 number is chosen because the default timeout for DNS clients is 5 seconds, after that they
Copy link
Member

Choose a reason for hiding this comment

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

I know you like to avoid knobs, but I can see use cases for setting this even lower so making it customizable makes sense to me.

The 5001 number is chosen because the default timeout for DNS clients is 5 seconds, after that they
give up.

A pluging interested in the cancelation status should call `plugin.Done()` on the context. If the
Copy link
Member

Choose a reason for hiding this comment

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

Should this be plumbed through the higher level plugin.NextOrFailure? Or just a best practice, in which case we should update other plugins to use it.

@miekg
Copy link
Member Author

miekg commented Mar 23, 2019 via email

@miekg
Copy link
Member Author

miekg commented Mar 23, 2019 via email

review feedback: add option to set custom timeout.

Signed-off-by: Miek Gieben <miek@miek.nl>
@codecov-io
Copy link

codecov-io commented Mar 23, 2019

Codecov Report

Merging #2711 into master will increase coverage by 0.04%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2711      +/-   ##
==========================================
+ Coverage    55.1%   55.14%   +0.04%     
==========================================
  Files         198      201       +3     
  Lines       10070    10151      +81     
==========================================
+ Hits         5549     5598      +49     
- Misses       4106     4134      +28     
- Partials      415      419       +4
Impacted Files Coverage Δ
plugin/done.go 0% <0%> (ø)
plugin/cancel/cancel.go 81.25% <81.25%> (ø)
plugin/metrics/setup.go 36.84% <0%> (-9.83%) ⬇️
plugin/forward/connect.go 81.69% <0%> (-4.23%) ⬇️
core/dnsserver/server.go 9.09% <0%> (-0.25%) ⬇️
plugin/backend_lookup.go 0% <0%> (ø) ⬆️
plugin/file/lookup.go 79.74% <0%> (ø) ⬆️
plugin/kubernetes/reverse.go 83.33% <0%> (ø) ⬆️
plugin/etcd/etcd.go 0% <0%> (ø) ⬆️
plugin/kubernetes/kubernetes.go 65.04% <0%> (ø) ⬆️
... and 11 more

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 a3dd8cd...84699e4. Read the comment docs.

@stp-ip
Copy link
Member

stp-ip commented Mar 24, 2019

lgtm, but waiting for @johnbelamaric to lgtm

Copy link
Member

@johnbelamaric johnbelamaric left a comment

Choose a reason for hiding this comment

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

Just fix these two typos in the docs and it's ready to go.

The 5001 number is chosen because the default timeout for DNS clients is 5 seconds, after that they
give up.

A pluging interested in the cancelation status should call `plugin.Done()` on the context. If the
Copy link
Member

Choose a reason for hiding this comment

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

s/pluging/plugin/

cancel [TIMEOUT]
~~~

* **TIMEOUT** allowss setting a custom timeout. The default timeout is 5001 milliseconds (`5001 ms`)
Copy link
Member

Choose a reason for hiding this comment

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

s/allowss/allows/

Signed-off-by: Miek Gieben <miek@miek.nl>
@miekg
Copy link
Member Author

miekg commented Mar 26, 2019 via email

@johnbelamaric
Copy link
Member

/lgtm

Copy link

@corbot corbot bot left a comment

Choose a reason for hiding this comment

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

LGTM by johnbelamaric

@miekg
Copy link
Member Author

miekg commented Mar 29, 2019

let's see if this works.

@miekg miekg merged commit ba87a0e into master Mar 29, 2019
@corbot corbot bot deleted the cancel branch March 29, 2019 19:40
Jason-ZW pushed a commit to rancher/coredns that referenced this pull request Apr 17, 2019
* plugin/cancel: add context cancelation plugin

Per review comments on coredns#2704, move this into a plugin that gets called.
Add the most minimal plugin, tests and documenation.

Signed-off-by: Miek Gieben <miek@miek.nl>

* plugin/cache: add timeout option

review feedback: add option to set custom timeout.

Signed-off-by: Miek Gieben <miek@miek.nl>

* spelling

Signed-off-by: Miek Gieben <miek@miek.nl>
dna2github pushed a commit to dna2fork/coredns that referenced this pull request Jul 19, 2019
* plugin/cancel: add context cancelation plugin

Per review comments on coredns#2704, move this into a plugin that gets called.
Add the most minimal plugin, tests and documenation.

Signed-off-by: Miek Gieben <miek@miek.nl>

* plugin/cache: add timeout option

review feedback: add option to set custom timeout.

Signed-off-by: Miek Gieben <miek@miek.nl>

* spelling

Signed-off-by: Miek Gieben <miek@miek.nl>
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.

4 participants