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

Service definition with an integrated check #280

Closed
fstradiotti opened this issue Feb 22, 2016 · 6 comments
Closed

Service definition with an integrated check #280

fstradiotti opened this issue Feb 22, 2016 · 6 comments

Comments

@fstradiotti
Copy link
Contributor

Hello,
I've updated my wrapper cookbook to use the latest version of this consul-cookbook and noticed that the service/check definition has changed a lot. I am trying to create a service definition with an integrated health check but after reading through the documentation and doing trials and errors I can't seem to figure out how it's done.

Previously I would have written something like this:

consul_service_def 'vault' do
  port 8200
  tags [
    'vault',
    'http'
  ]
  check(
    interval: '10s',
    http: 'http://127.0.0.1:8200/v1/sys/health',
    timeout: '5s'
  )
end

This is not allowed anymore so I tried doing it with the new type of consul_defitinion:

consul_definition 'vault' do
  type 'service'
  parameters(tags: 'vault, http', address: '127.0.0.1', port: 8200)
  notifies :reload, 'consul_service[consul]', :delayed
end

consul_definition 'vault_check' do
  type 'check'
  parameters(http: 'http://127.0.0.1:8200/v1/sys/health', interval: '10s', timeout: '5s')
  notifies :reload, 'consul_service[consul]', :delayed
end

This results in two independent resources which are not linked to each other. If I name both consul_definitions to "vault" then one will override the other one.

How would I create a service definition with an integrated check like I did in my first example? Can someone point me in the right direction please? Thanks!

@johnbellone
Copy link
Contributor

I think the only way to do this would be to update the consul_definition resource to have a parameter which accepts the parameters for the second resource.

@fstradiotti
Copy link
Contributor Author

So that does this mean that there is no way to implement a previously available feature?
Why did this useful feature get removed?

@gdavison
Copy link
Contributor

This works for me:

consul_definition 'flipper-ui' do
  type 'service'
  parameters(
    port:  8000,
    check: {
      interval: '10s',
      http:     'http://localhost:8000'
    }
  )
  notifies :reload, 'consul_service[consul]', :delayed
end

@fstradiotti
Copy link
Contributor Author

Thank you for the tip @gdavison, that was exactly what I was searching for.

I have created a PR to update the readme with an example code snippet as I think this is useful information that should be added: #281

@johnbellone
Copy link
Contributor

Thanks @fstradiotti and @gdavison !

@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

No branches or pull requests

3 participants