-
Notifications
You must be signed in to change notification settings - Fork 116
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
base: master
Are you sure you want to change the base?
Feature/http check #156
Conversation
* Use `PUT` as the verb for deregistering a service. Consul 1.0 has started to enforce the verbs used: *https://www.consul.io/docs/upgrade-specific.html#http-verbs-are-enforced-in-many-http-apis * Appease rubocop errors
If you can resolve the merge conflict, then this looks fine to merge. |
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
There was a problem hiding this 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?
lib/diplomat/check.rb
Outdated
# @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) |
There was a problem hiding this comment.
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)
lib/diplomat/check.rb
Outdated
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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
…tration_deregistration Support for tokens when registering/unregistering entities on Agent
…figuration Allow to pass Diplomat::Configuration object when using diplomat
@lremes Do you mind rebasing to include this PR with my suggestions? |
README: Drop defunct badge, use SVG
Suggest using X-Consul-Token for ACL tokens
@lremes Do you mind rebasing to include this PR with my suggestions? |
Support for Output in TTL checks
- Fix incorrect verbs for checks Fix WeAreFarmGeek#173 - Use json_pure to avoid the need for installing a compiler. Fix WeAreFarmGeek#177 - Allow updating Output with TTL checks WeAreFarmGeek#178
simpler convert_to_hash function
@lremes ping? Rebase it please, I'll close it if no answer in 1 month |
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
Rebasing. |
Adds register_http to access methods and Updated README and Changelog
… into feature/http-check # Conflicts: # CHANGELOG.md # README.md # lib/diplomat/check.rb
@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? |
Add support for registering a HTTP service check with consul