-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
The service consul is not present and restart fail #76
Comments
@lyrixx Does the recipe which makes call to "consul_service_def" includes "consul" recipe? I think if you include "consul" recipe, it will work. Meanwhile, I'll do more investigation when "consul" is applied on a node and not in the same recipe. |
Because LWRP creates its own run_content that is why we get the exception. To fix it, I can add the service resource in the recipe but we end up having 2 service definitions, in recipe and resource. Or, I can remove the service notification but caller will be responsible for restarting Consul on consul_service_def change. I'm leaning more towards the former. |
@thedebugger I actually ran into this problem myself yesterday and just hadn't gotten around to writing a PR to address the issue. I should have paid more attention before I had merged the work. The person who is writing the consul_service_def should notify the consul service that they want it to restart. I don't think it should be the job of the LWRP itself to attempt to reach out of it's run_context and notify the service resource. When I first read the PR I thought it was a nice optimization but didn't think it all the way through. I think we should go the path of least surprises and not try to define the service resource in two places. There are plenty of error conditions just waiting for us down that path. |
Yes, here is my include_recipe "consul"
if node['sensiolabs_consul']['serve_ui']
include_recipe "consul::ui"
end
include_recipe "sensiolabs_consul::system_checks"
node['sensiolabs_consul']['services'].each do |name, definition|
consul_service_def name do
id definition['id'] unless definition['id'].nil?
port definition['port'] unless definition['port'].nil?
tags definition['tags'] unless definition['tags'].nil?
check definition['check'] unless definition['check'].nil?
end
end About all your questions, I have no answer. Sorry. I'm really too junior with chef for that. |
@reset Caller notifying service['consul'] is a leaky abstraction. In the future, if we change the implementation of consul_service_def to an HTTP call, there is no need to notify the service['consul']. We can define the service['consul'] resource in a library so that it is at a single place. |
@thedebugger that's not a leaky abstraction at all. There is a clear definition between the inner workings of the LWRP and what the recipe is defining. That's why there are two run contexts. |
@reset IMO, the implementation of consul_service_def is leaky, since the caller has to decided based on the implementation if it has to notify service['consul'] or not. Won't it make sense to have the notification inside the consul_service_def if we aren't limited by different chef run contexts? IMO, it makes sense to do it within the consul_service_def instead of burdening the caller (plus, one can easly miss to notify service['consul']). |
@thedebugger the behaviour your describing makes perfect sense and is desirable. However, with the primitives we have the only way to properly accomplish it without coupling the internals of an LWRP to the recipe of a cookbook is to have the service resource subscribe to a wildcard of all Unless you are speaking about the state of the |
@reset I think you meant PR #70. Prior to it, IMO, no |
@thedebugger yes 70 I mean 70, though 74 is related. The consumer of the |
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. |
The error
My code:
I used
init
for service configurationThe text was updated successfully, but these errors were encountered: