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 · 5 comments

Comments

Projects
None yet
3 participants
@fstradiotti
Copy link
Contributor

commented Feb 22, 2016

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

This comment has been minimized.

Copy link
Contributor

commented Feb 22, 2016

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

This comment has been minimized.

Copy link
Contributor Author

commented Feb 22, 2016

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

@gdavison

This comment has been minimized.

Copy link
Contributor

commented Feb 22, 2016

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

This comment has been minimized.

Copy link
Contributor Author

commented Feb 23, 2016

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

This comment has been minimized.

Copy link
Contributor

commented Feb 23, 2016

Thanks @fstradiotti and @gdavison !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.