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

Fix reloading in plugin/pprof. #3454

Merged
merged 3 commits into from Nov 18, 2019
Merged

Fix reloading in plugin/pprof. #3454

merged 3 commits into from Nov 18, 2019

Conversation

@gonzalop
Copy link
Contributor

gonzalop commented Nov 16, 2019

Reloading the server without changing the listen address results in an
error because Startup is called for newly set up plugins before Shutdown
is called for the old ones.

1. Why is this pull request needed and what does it do?

When pprof is enabled, reloading the server stops listening on the pprof port.

g@t~/gonzalop/coredns#master$ curl http://127.0.0.1:6053/debug/pprof/heap > /dev/null 2>&1
g@t~/gonzalop/coredns#master$ echo $?
0
g@t~/gonzalop/coredns#master$ sudo service coredns reload
g@t~/gonzalop/coredns#master$ curl http://127.0.0.1:6053/debug/pprof/heap > /dev/null 2>&1
curl: (7) Failed to connect to 127.0.0.1 port 6053: Connection refused
g@t~/gonzalop/coredns#master$ git checkout pprof_reload > /dev/null
g@t~/gonzalop/coredns#pprof_reload$ make > /dev/null
g@t~/gonzalop/coredns#pprof_reload$ sudo install coredns /usr/bin/
g@t~/gonzalop/coredns#pprof_reload$ sudo service coredns restart
g@t~/gonzalop/coredns#pprof_reload$ curl http://127.0.0.1:6053/debug/pprof/heap > /dev/null 2>&1
g@t~/gonzalop/coredns#pprof_reload$ sudo service coredns reload
g@t~/gonzalop/coredns#pprof_reload$ curl http://127.0.0.1:6053/debug/pprof/heap > /dev/null 2>&1
g@t~/gonzalop/coredns#pprof_reload$ echo $?
0

2. Which issues (if any) are related?

None (I can create one if needed)

3. Which documentation changes (if any) need to be made?

None.

4. Does this introduce a backward incompatible change or deprecation?

None.

@corbot corbot bot requested a review from stp-ip Nov 16, 2019
@corbot

This comment has been minimized.

Copy link

corbot bot commented Nov 16, 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.
Note this is not an exclusive request. Anyone is free to provide a review of this pull request.

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.

@gonzalop gonzalop force-pushed the gonzalop:pprof_reload branch 2 times, most recently from b353e67 to e3e2d8a Nov 16, 2019
@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Nov 16, 2019

Codecov Report

Merging #3454 into master will increase coverage by 0.01%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3454      +/-   ##
=========================================
+ Coverage   56.59%   56.6%   +0.01%     
=========================================
  Files         221     221              
  Lines       10994   10992       -2     
=========================================
  Hits         6222    6222              
+ Misses       4288    4287       -1     
+ Partials      484     483       -1
Impacted Files Coverage Δ
plugin/pprof/pprof.go 0% <0%> (ø) ⬆️
plugin/pprof/setup.go 93.93% <100%> (-0.35%) ⬇️
plugin/file/reload.go 75% <0%> (+5.55%) ⬆️

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 f100d61...afd9ffa. Read the comment docs.

@miekg

This comment has been minimized.

Copy link
Member

miekg commented Nov 16, 2019

Ha, wasn't aware this package already exists. Note this is a thin wrapper around "golang.org/x/sys/unix" which is already used via miekg/dns and that functionality also exists there https://github.com/miekg/dns/blob/master/listen_go111.go

IOW: it would be great to add a very minimal package as pkg/reuseport and use that.

Looking further we already have those bits in https://github.com/coredns/coredns/blob/master/core/dnsserver/listen_go111.go. We should extract that and make it more generally available so other plugins can easily use it.

@miekg

This comment has been minimized.

Copy link
Member

miekg commented Nov 16, 2019

See #3455

@gonzalop

This comment has been minimized.

Copy link
Contributor Author

gonzalop commented Nov 16, 2019

See #3455

Great! I can update this change once yours is approved.

@gonzalop gonzalop force-pushed the gonzalop:pprof_reload branch 2 times, most recently from 435e9cd to 2759160 Nov 16, 2019
Reloading the server without changing the listen address results in an
error because Startup is called for newly set up plugins before Shutdown
is called for the old ones.

Signed-off-by: Gonzalo Paniagua Javier <gonzalo.mono@gmail.com>
@gonzalop gonzalop force-pushed the gonzalop:pprof_reload branch from 2759160 to f709f6e Nov 17, 2019
Use coredns' newly added reuseport.

Signed-off-by: Gonzalo Paniagua Javier <gonzalo.mono@gmail.com>
@gonzalop gonzalop force-pushed the gonzalop:pprof_reload branch from f709f6e to 0b156a0 Nov 17, 2019
@miekg

This comment has been minimized.

Copy link
Member

miekg commented Nov 17, 2019

lgtm, the go.{mod,sum} changes should be reverted though

Signed-off-by: Gonzalo Paniagua Javier <gonzalo.mono@gmail.com>
@gonzalop gonzalop force-pushed the gonzalop:pprof_reload branch 2 times, most recently from 45a40fb to afd9ffa Nov 17, 2019
@gonzalop

This comment has been minimized.

Copy link
Contributor Author

gonzalop commented Nov 17, 2019

lgtm, the go.{mod,sum} changes should be reverted though

Done. Ty.

@miekg miekg merged commit f91c55d into coredns:master Nov 18, 2019
5 checks passed
5 checks passed
DCO DCO
Details
ci/circleci: kubernetes-tests Your tests passed on CircleCI!
Details
codecov/project 56.57% (target 50%)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
stickler-ci No lint errors found.
@miekg

This comment has been minimized.

Copy link
Member

miekg commented Nov 18, 2019

@gonzalop gonzalop deleted the gonzalop:pprof_reload branch Nov 18, 2019
gonzalop added a commit to gonzalop/coredns that referenced this pull request Nov 23, 2019
* Fix reloading in plugin/pprof.

Reloading the server without changing the listen address results in an
error because Startup is called for newly set up plugins before Shutdown
is called for the old ones.

Signed-off-by: Gonzalo Paniagua Javier <gonzalo.mono@gmail.com>

* Use pkg/reuseport when listening.

Use coredns' newly added reuseport.

Signed-off-by: Gonzalo Paniagua Javier <gonzalo.mono@gmail.com>

* Revert go.{mod,sum} changes.

Signed-off-by: Gonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.