-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
cli: update generated haproxy config with readiness endpoint #23463
Conversation
Will cherrypick this into 2.0. |
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 assume you tested this manually to make sure haproxy responds appropriately to a node being unhealthy?
@@ -107,6 +145,7 @@ listen psql | |||
bind :26257 | |||
mode tcp | |||
balance roundrobin | |||
{{range .}} server cockroach{{.Desc.NodeID}} {{.Desc.Address.AddressField}} check | |||
option httpchk GET /health?ready=1 |
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.
Does httpchck
work for HTTPS endpoints automatically or do you need to tweak this for secure clusters?
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.
Tested it with a secure cluster and it works fine.
pkg/cli/haproxy.go
Outdated
@@ -75,7 +89,31 @@ func runGenHAProxyCmd(cmd *cobra.Command, args []string) error { | |||
w = f | |||
} | |||
|
|||
err = configTemplate.Execute(w, nodeStatuses.Nodes) | |||
fs := flag.NewFlagSet("haproxy", flag.ContinueOnError) |
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 logic could use a unit test
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.
Done, thanks for the suggestion. It caught a bug regarding not reinitializing state between loops.
Yeah, I did test this manually. |
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. If @mberhault is back online it'd be nice to have him confirm this, but it looks good to me.
pkg/cli/haproxy_test.go
Outdated
Args: []string{"-http-port"}, | ||
}, | ||
} | ||
expected := []haProxyNodeInfo{ |
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.
Nit, but the convention throughout most of the code base is to include the expected results next to the input that generates them, rather than in separate slices that readers have to mentally join together. You can leave this is as if you want, though.
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.
No problem! Updated.
Release note (cli change): The generated haproxy config has been extended with readiness checks.
Release note (cli change): The generated haproxy config has been
extended with readiness checks.