-
Notifications
You must be signed in to change notification settings - Fork 184
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 #11 #13
fix #11 #13
Conversation
- Add consul-template - Update existing examples - Clean up some scripts Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
I've updated |
Forgot to mention:
|
@@ -0,0 +1,23 @@ | |||
#!/usr/bin/with-contenv sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have a couple of ideas to make this part a little more elegant.
s6 has the concept of a down
file, http://skarnet.org/software/s6/servicedir.html. If a down
file exists in a service directory, s6 won't start the service. This container should have a down
file in root/etc/services.d/consul-template
by default.
We can then move the num templates logic into an init script, https://github.com/just-containers/s6-overlay#executing-initialization-andor-finalization-tasks. The init script would remove the down
file if there was something for consul-template
to do.
In order to stop consul-template
running indefinitely, after everything has finished, we could done one of two things:
- use
s6-svc -d /var/run/s6/services/consul-template
to bring down this service and don't restart it - or write a
down
file, and then exit (s6 will notice thedown
file and not restart it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, perhaps the looping logic could be tidied up by changing this from a shell script to an execline script and utilising s6-svwait, http://skarnet.org/software/s6/s6-svwait.html. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to stop consul-template running indefinitely
It is meant to run indefinitely as it monitors changes and updates files accordingly. That is why there's s6 command to restart, see examples/user-consul-nginx-nodejs/root/etc/consul-template/conf.d/nginx/nginx.conf and command = "s6-svc -h /var/run/s6/services/nginx"
.
I will add the down
file and init script as that is exactly what is needed. Thanks for pointing this feature out!
Also, perhaps the looping logic could be tidied up by changing this from a shell script to an execline script and utilising s6-svwait
I did try s6-svwait but unfortunately what happens is that while consul agent
is up it is not usable immediately causing consul-template
to throw up an error as it tries to query for data for templates. We could try notification-fd however I am not really sure how to implement this. If you have an example or know how to please let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best way to handle this stuff is through s6-rc
which is brand new. You can view this issue on s6-overly for more information just-containers/s6-overlay#112. Until then, I think we should keep it really simple and run with the loop. At such a time s6-rc is integrate into s6-overlay, then we can refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matthewvalimaki, I was reading the consul-template
documentation a little more (I haven't actually used it before). Could we make use of the retry
option? Would that cause consul-template
not to error? Perhaps then we could remove the Consul nodes watch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smebberson I haven't been clear. It does retry but problem is that it
logs an error. So what I'm trying to avoid is that error from happening.
Nothing crashes and consul-template does continue to work correctly.
On Dec 16, 2015 4:22 PM, "Scott Mebberson" notifications@github.com wrote:
In alpine-consul/root/etc/services.d/consul-template/run
#13 (comment)
:@@ -0,0 +1,23 @@
+#!/usr/bin/with-contenv sh@matthewvalimaki https://github.com/matthewvalimaki, I was reading the
consul-template documentation a little more (I haven't actually used it
before). Could we make use of the retry option? Would that cause
consul-template not to error? Perhaps then we could remove the Consul
nodes watch?—
Reply to this email directly or view it on GitHub
https://github.com/smebberson/docker-alpine/pull/13/files#r47854240.
@matthewvalimaki, to make this super complete I think it might need a |
@matthewvalimaki, btw, thanks for this. It's going to be a great addition. I'm happy to help add the extra bits and pieces if you like. |
@smebberson No need for And no problem, I like these Docker images and use them myself and want to improve them so that I have less to worry about downstream :) |
Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
… to be brought up when templates actually exist. Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
…to use it Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
@smebberson Improvements pushed, see matthewvalimaki@ae74691. |
@matthewvalimaki, these changes look great. Given the scenario we're faced with, the loop you have implemented should work fine. To implement notifications, well, I think it will require some effort from Consul's part. But I think we should raise it as a bug. Either I wasn't aware that Thanks again. I'll look to merge this in ASAP. |
@smebberson actually I believe by using
Then in combination with consul handler executing a shell script we should be able to know when
{
"watches": [
{
"type": "nodes",
"handler": "/usr/sbin/consul-nodes-handler.sh"
}
]
} consul-nodes-handler.sh would then be responsible for:
Unfortunately as it is https://github.com/smebberson/docker-alpine/blob/master/alpine-consul-base/root/etc/services.d/consul/run is recursively set to go through
|
@matthewvalimaki, yep, I like the sound of that. I think that would be a great addition and tidy things up nicely! Great suggestion. |
…onf.d - Update consul-template setup Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
- Move consul-nodes-handler from sbin to bin to better reflect other images Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
@smebberson I've updated code to reflect what was discussed earlier with one exception: |
fi | ||
|
||
# 3) Execute `s6-svc -u` to notify supervisor that service should start | ||
s6-svc -u /var/run/s6/services.d/consul-template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be s6-svc -u /var/run/s6/services/consul-template
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should. Thanks for spotting this. I'll take care of it.
Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
- Remove useless loop which was replaced by init and additional script - Fix down file location from /etc to /var/run/s6/services/consul-template/down which is created by s6-overlay stage 2. Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
@matthewvalimaki, sorry, I didn't realise this was ready for review again. I assume it is? |
No problem and yes it is ready again.
|
#!/usr/bin/execlineb -S1 | ||
|
||
# only tell s6 to bring down the entire container, if it isn't already doing so | ||
# http://skarnet.org/software/s6/s6-supervise.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matthewvalimaki, I think it would be better if consul-template
automatically restarted rather than bringing down the container (to do this just remove this file). consul-template
is a secondary service to consul itself and I think it would be fine to have s6 automatically restart it.
I think it would also go aways to resolving the consul-template
runs before consul
is ready issue (aside from the retry
option I've just commented about).
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matthewvalimaki, we might even be able to add a sleep 1
in the finish script so that s6 doesn't restart it so quickly.
I guess I'm just not 100% on the consul watch to wait for nodes. I definitely like it better than the shell loop. But it just feels like it is making the container logic heavy
. But, without s6-rc, if that is what it takes, then that is what it takes I guess.
Anyway, let me know your final thoughts and if you think the container definitely needs the watch, then I'll get to merging it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smebberson not a big deal to me but my reasoning against would be that if
template fails it means that configuration probably failed too and so
template in my mind is as essential as consul. In the end user defines
behavior so again not a big deal.
On Dec 16, 2015 4:46 PM, "Scott Mebberson" notifications@github.com wrote:
In alpine-consul/root/etc/services.d/consul-template/finish
#13 (comment)
:@@ -0,0 +1,8 @@
+#!/usr/bin/execlineb -S1
+
+# only tell s6 to bring down the entire container, if it isn't already doing so
+# http://skarnet.org/software/s6/s6-supervise.html@matthewvalimaki https://github.com/matthewvalimaki, I think it would
be better if consul-template automatically restarted rather than bringing
down the container (to do this just remove this file). consul-template is
a secondary service to consul itself and I think it would be fine to have
s6 automatically restart it.I think it would also go aways to resolving the consul-template runs
before consul is ready issue (aside from the retry option I've just
commented about).What do you think?
—
Reply to this email directly or view it on GitHub
https://github.com/smebberson/docker-alpine/pull/13/files#r47856359.
@smebberson I'll do those group changes. @smebberson according to init-stages stage 2 i. @smebberson to me it feels like s6-overlay should have 4th step in stage 2 after copying files. |
…image versions. Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
@smebberson Running Right now this problem is solved for To make things cleaner we could introduce a new group which owns, along with root, all |
@matthewvalimaki, have you seen the response in just-containers/s6-overlay#130 ? This goes along with our thinking. Let's set it up as you've stated: Introduce a new group which owns, along with root, all I would like to some how keep this out of the individual run scripts if possible, do you agree? I agree with your sentiment about a 4th stage. I'll follow up in the same issue on s6-overlay and see what happens. |
@matthewvalimaki, it seems as though we should be able to set everything up in some |
@matthewvalimaki, are you still keen on pushing this one through? |
Yes. I am currently on vacationing causing the delay.
|
@smebberson I tested the idea of setting permissions on Unfortunately |
Okay, cool. No worries, thanks for following that up. So, is everything ready in this PR to be merged? |
@matthewvalimaki, ping! Let me know if this is ready to go. I want to get this merged and then resolve the other issues on this repo. Thanks! |
Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
…mplate` work properly with `s6-svc`. Signed-off-by: Matthew Valimaki <matthew.valimaki@gmail.com>
@smebberson pong! Sorry for the delay. This PR has existed far too long. Not only has it held back new releases but it's hard to capture all that has been discussed even when those are written above. Please review if All changes were made to
|
@matthewvalimaki, this looks good. I'm going to pull this down, work it up a little more and then merge it into master. We can always improve on things along the way. My gut feel is this is a little heavy straight in I'll get onto this first thing tomorrow morning (don't want to start this so late in the day here). |
@smebberson sounds good. Please do whatever changes you want. I just want On Tue, Mar 1, 2016 at 1:29 AM, Scott Mebberson notifications@github.com
|
@smebberson understanding that this + other issues cause quite a backlog but I was wondering how is it going? Do you need help with anything? I rather help you with this project than start maintaining my fork so let me know if there's anything I could do. I have quite a few things depending on these images :) |
@matthewvalimaki. Sorry! Working on it now ;) |
@matthewvalimaki, I'm getting some weird errors and I can't get it to run. I guess you weren't experience anything like the below?
I don't have heaps of experience with consul-template so I'm not sure what it would be doing. Or even why it would be looking in that directory? Any ideas? |
@matthewvalimaki, I managed to get past that. Running into a few other issues now. But I'm working through them. |
Sorry, sounds like I made a broken or :( A side note: remember that we can use pre-built consul binary as of 0.6.
|
@matthewvalimaki, take a look at https://github.com/smebberson/docker-alpine/tree/matthewvalimaki-add-consul-template. That is my integration branch. Everything seems to be running smoothly now. There was a number of issues due to permissions not allowing certain things to occur (such as removing the consul nodes watch symlink - you didn't experience anything like that?). The only thing I'm not happy with is the weird permissions I had to have on the
Despite the fact that If you want to run this locally, you'll have to build (in this order):
If you could give me your input on that - that'd be great. I'll wait to merge into master until you get back to me. Also, before I merge into master, I'll release v1.0.0 of |
@smebberson please merge #12 while you're at working on nodejs :) I'll think about your questions now and see if I can come up with something. Thanks for the cleanup. |
@smebberson going back to your last questions:
I did! And I thought I pushed up those fixes, very similar to what you did. I'm sorry, I should've made a clean clone to test it again. The symlink was one of the very first permissions issues I encountered. Do you still have similar issues elsewhere?
I did not see that. Probably having Windows as host causes some issues for permissions for me. As the file you mentioned, |
@matthewvalimaki this is finally done! I've version bumped and Git tagged, and Docker hub tagged |
@smebberson awesome! Good job! Now I get to provide Nomad and other
|
Signed-off-by: Matthew Valimaki matthew.valimaki@gmail.com