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

Add support for health-checks to consul_service #64

Merged
merged 12 commits into from
Mar 19, 2019

Conversation

remilapeyre
Copy link
Contributor

As proposed in #54, this patch add the support for health-checks defined inline in Consul services definition.

@ghost ghost added the size/L label Sep 17, 2018
@pearkes
Copy link
Contributor

pearkes commented Oct 22, 2018

Made a few notes about this in the issue: #54 (comment)

@remilapeyre
Copy link
Contributor Author

I used this version of the code for a few weeks and I think there is some problem for the update, I need to add some tests.

@pearkes
Copy link
Contributor

pearkes commented Oct 30, 2018

@remilapeyre do you think this would be cleaner with the addition of hashicorp/consul#1680? I think that'd make it much clearer but would require another upstream change. Thoughts?

@remilapeyre
Copy link
Contributor Author

This would be better as we could detect changes in checks from other sources.
I think it is not required for the first version of theis PR if we put an information about changes done outside from terraform not being detected. For example, for my needs no other service would have made changes to the checks defined in terraform and it would have still been useful.

Is there a reason hashicorp/consul#1680 (comment) does not use the same fields than https://www.consul.io/api/agent/check.html#register-check? Does his message predates the introduction of https://www.consul.io/api/agent/check.html#register-check?

@pearkes
Copy link
Contributor

pearkes commented Mar 4, 2019

@remilapeyre I feel like we should just get this merged in the current approach, and not necessarily wait for that upstream change. Does that sound good to you?

@remilapeyre
Copy link
Contributor Author

Hi @pearkes, I'm getting confused about the issue, if I understand hashicorp/consul#1680 correctly, the information is already available since Consul v1.0.1.

Health-Checks definitions were first added in a7c42a6c2a3c63331170e2fee6ca1bc7bf6731e9 (Expose SkipNodeUpdate field and some health check info in the http api), then refined in subsequents commits.

Here's what http://localhost:8500/v1/health/checks/example-external gives since v1.0.1:

[
    {
        "Node": "external-example",
        "CheckID": "service:redis1",
        "Name": "Redis health check",
        "Status": "critical",
        "Notes": "Script based health check",
        "Output": "",
        "ServiceID": "example-external",
        "ServiceName": "example-external",
        "ServiceTags": [],
        "Definition": {
            "HTTP": "https://www.google.com",
            "Interval": "5s",
            "Timeout": "1s"
        },
        "CreateIndex": 9,
        "ModifyIndex": 10
    }
]

It seems to me that it is just the documentation at https://www.consul.io/api/health.html#list-checks-for-service that is not up to date.

If this is right, this PR need documentation and to make header support in checks work.

@pearkes
Copy link
Contributor

pearkes commented Mar 8, 2019

I'm suggesting we change Consul to return the health checks in the same API response as when querying for service instances. Currently it just returns the health check status, not definition.

But in the interim I'm supportive of this current approach of using the (separate) heath check API to read the health check definitions. Would just be nice if we could do it in one API call, but not a big deal.

this PR need documentation and to make header support in checks work.

That makes sense to me!

@remilapeyre remilapeyre changed the title Add support for services health-checks Add support for services health-checks to consul_service Mar 18, 2019
@remilapeyre remilapeyre changed the title Add support for services health-checks to consul_service Add support for health-checks to consul_service Mar 18, 2019
Copy link
Contributor

@pearkes pearkes left a comment

Choose a reason for hiding this comment

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

Nice work. Looks good I just think we shouldn't nest under definition.

consul/resource_consul_service_test.go Outdated Show resolved Hide resolved
consul/resource_consul_service.go Outdated Show resolved Hide resolved
@remilapeyre remilapeyre requested a review from pearkes March 18, 2019 20:41
Copy link
Contributor

@pearkes pearkes left a comment

Choose a reason for hiding this comment

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

Great job 👍

@remilapeyre remilapeyre merged commit 9dd81e5 into hashicorp:master Mar 19, 2019
remilapeyre pushed a commit to remilapeyre/terraform-provider-consul that referenced this pull request Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants