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

Feature/http check #156

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open

Conversation

lremes
Copy link

@lremes lremes commented Oct 5, 2017

Add support for registering a HTTP service check with consul

@taharah
Copy link
Member

taharah commented Nov 26, 2017

If you can resolve the merge conflict, then this looks fine to merge.

sixfeetover and others added 4 commits December 28, 2017 14:02
Concerning ACL tokens, the Consul documentation (https://www.consul.io/api/index.html#authentication) says:

> Previously this was provided via a ?token= query parameter. This functionality exists on many endpoints for backwards compatibility, but its use is highly discouraged, since it can show up in access logs as part of the URL.

The `config.acl_token` setting in Diplomat sets the `token` query string parameter rather than the header. Additionally, it does not set it for all API endpoints (e.g., Services). Setting the header instead fixes both issues.
There is no need for a separate module, all these methods are only used
within the rest client.
In some cases you might want to have multiple ::Diplomat::RestClient at
the same time but with different configurations. Using a static config
forbid this kind of uses.

Possible use cases:
- Multiple clients with different Tokens
- Multiple clients pointing to different Consul cluster

This commit should fix WeAreFarmGeek#159
Copy link
Member

@pierresouchay pierresouchay left a comment

Choose a reason for hiding this comment

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

Would you mind rebasing and performing a few changes?

# @param ttl [String] time (with units) to mark a check down
# @return [Integer] Status code
#
def register_http(check_id, name, notes, url, method, header, interval)
Copy link
Member

Choose a reason for hiding this comment

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

There are lots of parameters to this function, would you mind using named parameters instead ?

I would rather use this signature:

def register_http(url, interval, id: nil, id:name, notes: nil, method: 'GET', header: nil)
  [...]
end

since both interval and url are mandatory (see https://www.consul.io/api/agent/check.html#register-check )
It would allow to use only the provided parameters.

It also lacks header in ruby documentation as well as calling it headers would probably be more accurate (and specify type)

ret = @conn.put do |req|
req.url '/v1/agent/check/register'
req.body = JSON.generate(
'ID' => check_id, 'Name' => name, 'Notes' => notes, 'HTTP' => url, 'Method' => method,
Copy link
Member

Choose a reason for hiding this comment

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

timeout might be interesting as well

@@ -32,6 +32,12 @@
expect(check.register_script('foobar-1', 'Foobar', 'Foobar test', '/script/test', '10s')).to eq(true)
end

it 'register_http' do
Copy link
Member

Choose a reason for hiding this comment

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

Please also test wrong value for parameters:

example:

curl -i --request PUT -d '{"ID":1, "http":"localhost:8500", "interval": "3x"}' http://localhost:8500/v1/agent/check/register
HTTP/1.1 400 Bad Request
Vary: Accept-Encoding
Date: Fri, 25 May 2018 06:52:59 GMT
Content-Length: 78
Content-Type: text/plain; charset=utf-8

@pierresouchay
Copy link
Member

@lremes Do you mind rebasing to include this PR with my suggestions?

@pierresouchay pierresouchay added the needs-rebase Needs rebase the PR label Dec 19, 2018
@pierresouchay
Copy link
Member

@lremes Do you mind rebasing to include this PR with my suggestions?

@pierresouchay
Copy link
Member

@lremes ping? Rebase it please, I'll close it if no answer in 1 month

tionebsalocin and others added 12 commits March 11, 2019 12:03
Using the configs hash target host or token can be
different at each call
…where

Enable configuration override on each consul api call
Set flags attribute on KVPair during lock acquisition and release
…ek#181)

* Avoid having a HTTP 302 if key requested starts with '/'

This might fix: WeAreFarmGeek#171

* Fixed rubocop warning
This release cleanup a lot the existing APIs while preserving ascending compatibility.
It will avoid relying on side effects to configure diplomat and allow to override most
configuration options per API call as implemented in WeAreFarmGeek#179.
It is now easy to use one instance of the lib and to perform several calls with different tokens and/or
consistency options for instance.
As every data was converted to json, raw data
usage was impossible

Reverting all json conversion to source function and
remove systematic conversion.

Fixes: WeAreFarmGeek#187
@lremes
Copy link
Author

lremes commented Mar 20, 2019

Rebasing.

Lars Remes and others added 3 commits March 20, 2019 09:29
Adds register_http to access methods and Updated README and Changelog
… into feature/http-check

# Conflicts:
#	CHANGELOG.md
#	README.md
#	lib/diplomat/check.rb
@pierresouchay
Copy link
Member

@lremes can you fix the tests?

@lremes
Copy link
Author

lremes commented May 21, 2019

@lremes can you fix the tests?

What do you want the changelog to say, as it is the only conflict and you need to edit it anyway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Needs rebase the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet