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

Improved the _start() method in the sysv initscript. Until now a sta… #433

Merged
merged 6 commits into from
May 19, 2017
Merged

Conversation

MichaelKueller
Copy link
Contributor

…rt of the consul agent followed by a reload will interrupt the start process and the consul agent will be stopped

You can simply reproduce this by calling:
/etc/init.d/consul restart; /etc/init.d/consul reload; /etc/init.d/consul status

This is likely to happen if you make a change in a wrapper cookbook that triggeres a consul restart and another change which triggeres a consul reload. Your consul agent will be stopped afterwards.

To fix this this change will make sure the consul service is started before leaving the _start() method.

…t of the consul agent followed by a reload will interrupt the start process and the consul agent will be stopped

You can simply reproduce this by calling:
/etc/init.d/consul restart; /etc/init.d/consul reload; /etc/init.d/consul status

 This is likely to happen if you make a change in a wrapper cookbook that triggeres a consul restart and another change which triggeres a consul reload. Your consul agent will be stopped afterwards.

  To fix this this change will make sure the consul service is started before leaving the _start() method.
@legal90
Copy link
Contributor

legal90 commented May 8, 2017

@MichaelKueller Thank you!
But I see that this fix covers only Debian platform. Could you please make it universal by moving this hook to a standalone function, like _wait_for_listening?


echo -n "Waiting for consul daemon to be listening..."
for i in `seq 1 30`; do
if ! start-stop-daemon --quiet --stop --test --pidfile $pidfile --user $user; then

This comment was marked as outdated.

@codecov-io
Copy link

codecov-io commented May 9, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@b4c3c47). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #433   +/-   ##
=========================================
  Coverage          ?   55.02%           
=========================================
  Files             ?        7           
  Lines             ?      358           
  Branches          ?        0           
=========================================
  Hits              ?      197           
  Misses            ?      161           
  Partials          ?        0

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 b4c3c47...2df9715. Read the comment docs.

@MichaelKueller
Copy link
Contributor Author

@legal90 good point! I changed the code accordingly.

@MichaelKueller
Copy link
Contributor Author

@legal90 I moved the hook to a _wait_for_listening function. I did not call it from the non-debian _start function though. After testing this with centos it turns out that the underlying issue does not exist there.

Copy link
Contributor

@legal90 legal90 left a comment

Choose a reason for hiding this comment

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

@MichaelKueller Thanks! Sorry for a slow response, but I've got the error of the firs iteration while testing Consul restart on Debian 7. We might need to rework the approach a little bit.

echo -n "Waiting for consul daemon to be listening..."
for i in `seq 1 30`; do
# if ! start-stop-daemon --quiet --stop --test --pidfile $pidfile --user $user; then
if ! _status_q; then

This comment was marked as outdated.

This comment was marked as outdated.

@legal90
Copy link
Contributor

legal90 commented May 19, 2017

@MichaelKueller @ZbigniewZabost-zanox Thank you!


@johnbellone Could you please disable Codecov integration for pull-requests?

@legal90 legal90 merged commit a0595fb into sous-chefs:master May 19, 2017
@legal90
Copy link
Contributor

legal90 commented May 24, 2017

@MichaelKueller @ZbigniewZabost-zanox
Hi guys! Seems like the method we've introduced here will not work with Consul 0.8+ having ACL enabled. In this case consul info could not be used for checking a service status because it always returns "403 Permission Denied", requesting the ACL token to be passed there.
Here is the test failure on Debian 7: https://travis-ci.org/johnbellone/consul-cookbook/jobs/235152247 (from PR: #434)

Do you have any ideas how we can avoid using consul info in init scripts ?

@moofish32
Copy link

@legal90 -- I think we have to move the ACL into the environment of the process manager scripts. The v8 ACL touches all commands AFAIK. The variable would be CONSUL_HTTP_TOKEN I think. The other option is prevent the cookbook from calling restart followed by reload and add a note for the user. The issue I opened #438 is a duplicate of the problem here. What are the key use cases requiring reload for current consumers? As 0.8 is a fairly serious change (with the raft update), perhaps this is a good opportunity to roll a major here as well and remove the reload.

legal90 added a commit to legal90/consul-cookbook that referenced this pull request May 27, 2017
@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants