-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
agent: support custom header and method for http checks (#3106) #3107
Conversation
fdbe311
to
fcb8621
Compare
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.
Noted a couple small things - otherwise looks good once tests are added. You'll also need to update the documentation.
Timeout string `json:",omitempty"` | ||
TTL string `json:",omitempty"` | ||
HTTP string `json:",omitempty"` | ||
Header map[string][]string `json:",omitempty"` |
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.
Headers
, maybe?
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.
I used https://golang.org/pkg/net/http/#Header as an example. But we also have header configuration in the config file which is Headers
and allows only a single value per header name. :( (https://github.com/hashicorp/consul/blob/master/command/agent/config.go#L704-L705)
Generally, I prefer to use what the stdlib is using (Header
with map[string][]string
) since then there is no necessity for type conversion and the names are the same. I'd also try/deprecate the other value but I'm open for suggestions.
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.
Ok - better to match the std lib for new things.
command/agent/config.go
Outdated
@@ -1437,6 +1437,20 @@ func FixupCheckType(raw interface{}) error { | |||
case "service_id": | |||
rawMap["serviceid"] = v | |||
delete(rawMap, k) | |||
case "header": | |||
vm, ok := v.(map[string]interface{}) |
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.
This seems like it should be returning errors if things aren't what we expect, otherwise we could silently skip these.
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.
I'll add that but I want to have a closer look at this method in general since it looks like mangling map[string]interface{}
is the wrong approach to this. But that could be fixed with the decoupling of user and runtime config where user config represents exactly what the user is providing and then we just parse the JSON and interpret it afterwards instead of mangling it.
fcb8621
to
bde7c4a
Compare
bde7c4a
to
0767510
Compare
de8d239
to
f51bc0e
Compare
f51bc0e
to
3df4999
Compare
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.
LGTM - just needs a mention in the docs https://github.com/hashicorp/consul/blob/master/website/source/docs/agent/checks.html.md
🤦♂️ forgot the docs. Will add. |
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.
LGTM
@magiconair thank you! 👍 |
Still need to write a test