-
Notifications
You must be signed in to change notification settings - Fork 324
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
Enable the ability to configure the ClientTimeout of the http client that interacts with the Consul API #1178
Conversation
dd25c96
to
c6357b7
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.
Excellent work @jmurret !!!
@@ -43,3 +43,13 @@ func TestNewClient(t *testing.T) { | |||
UserAgentHeader: fmt.Sprintf("consul-k8s/%s", version.GetHumanVersion()), | |||
}, consulAPICalls[0]) | |||
} | |||
|
|||
func TestNewClient_httpClientDefaultTimeout(t *testing.T) { |
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.
❤️
…t when new is passed with a config that contains an http client.
… SetClientTransportWithTLSConfig() have been exposed to allow getting access to Transport and TLSConfig defaulting when passing in your own http client.
430b09b
to
42b4394
Compare
…FromNonDefaultPartition since it timed out.
…omNonDefaultPartition to 30s to see if it does not timeout and the test passes.
…romNonDefaultPartition as it was using 5ns and timing out.
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 | ||
github.com/hashicorp/consul/api v1.10.1-0.20220413234639-3e88f579fce3 | ||
github.com/hashicorp/consul/api v1.10.1-0.20220425143126-6d0162a58a94 |
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 temporarily points to consul core dev branch.
github.com/hashicorp/consul/api v1.10.1-0.20220421045807-e7bb156a82e2 h1:kwb0ddQK6XTg9AVQgxe517Q0vrJ7MIPMIrp0yP/EZbE= | ||
github.com/hashicorp/consul/api v1.10.1-0.20220421045807-e7bb156a82e2/go.mod h1:ZlVrynguJKcYr54zGaDbaL3fOvKC9m72FhPvA8T35KQ= | ||
github.com/hashicorp/consul/api v1.10.1-0.20220425143126-6d0162a58a94 h1:mPhpaeGO4BmD0Fi9gmevT7kYDyDml1kNjf0HKCFF5xM= | ||
github.com/hashicorp/consul/api v1.10.1-0.20220425143126-6d0162a58a94/go.mod h1:ZlVrynguJKcYr54zGaDbaL3fOvKC9m72FhPvA8T35KQ= |
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 temporarily points to consul core dev branch.
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.
Excellent work on the PR @jmurret !!
// Splitting this into two asserts on fragments of the error because the error thrown | ||
// can be either of the two below and matching on the whole string causes the test tobe flakey | ||
// "1 error occurred:\n\t* Get \"http://126.0.0.1:31200/v1/agent/services?filter=Meta%5B%22k8s-service-name%22%5D+%3D%3D+%22service-created%22+and+Meta%5B%22k8s-namespace%22%5D+%3D%3D+%22default%22+and+Meta%5B%22managed-by%22%5D+%3D%3D+%22consul-k8s-endpoints-controller%22\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)\n\n" | ||
// "1 error occurred:\n\t* Get \"http://126.0.0.1:31200/v1/agent/services?filter=Meta%5B%22k8s-service-name%22%5D+%3D%3D+%22service-created%22+and+Meta%5B%22k8s-namespace%22%5D+%3D%3D+%22default%22+and+Meta%5B%22managed-by%22%5D+%3D%3D+%22consul-k8s-endpoints-controller%22\": dial tcp 126.0.0.1:31200: i/o timeout (Client.Timeout exceeded while awaiting headers)\n\n" |
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.
Thanks for the rationale! This makes sense.
@@ -234,6 +228,23 @@ func (c *Command) Run(args []string) int { | |||
return 0 | |||
} | |||
|
|||
func (c *Command) validateFlags() error { |
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.
❤️
@@ -161,3 +169,43 @@ func (s *StringValue) String() string { | |||
} | |||
return current | |||
} | |||
|
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 is excellent!!!
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.
So thorough!! LGTM!
@@ -161,3 +169,43 @@ func (s *StringValue) String() string { | |||
} | |||
return current | |||
} | |||
|
|||
// DurationValue provides a flag value that's aware if it has been set. | |||
type DurationValue struct { |
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.
How are these DurationValue functions being used/meant to be used? Was it because we didn't have any duration related flags before and all duration flags need to implement 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.
Yes, the StringValue was copied from this same file from consul core: https://github.com/hashicorp/consul/blob/21e855d860865f1472b3fdcb64a916e92bc83a9f/command/flags/config.go#L91 and there is a comment at the top of this file from a while ago about why we have copied them.
I originally had this an IntValue but ultimately it is going to become a duration and we already have some places in our helm values where you can configure duration like "5s", "500ms", etc., so I changed it to make it consistent and more flexible.
Related to issue: #714
Note: This PR imports the consul api package from the branch in this PR rather than a released version. We have validated that this change works for the customer and will update this PR when the COnsul change gets merged.
Changes proposed in this PR:
global. consulAPITimeout
with a default of 5scharts/consul/templates
passes-consul-api-timeout={{ .Values.global.consulAPITimeout }}
to control-plane commandscharts/consul/test/unit
asserts that those argument passings occur.control-plane/
ensures:-consul-api-timeout
is greater than zero-consul-api-timeout
is used when creating consul ClientHow I've tested this PR:
How I expect reviewers to test this PR:
Checklist: