-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Unexpected DNS caching #726
Comments
Hi @paulgrav, That is expected, we cache the DNS records for the whole period of the test in order to maximize the throughput. https://github.com/loadimpact/k6/blob/9531175bc4f5b525655db6c8f96865689bb215e7/lib/netext/dialer.go#L54 I guess it would be nice to have an option to set the DNS caching time, what do you think @na-- ? |
Yeah, caching DNS records forever doesn't seem like the most flexible solution. It may be fine for simple tests, but some flexibility would be best, even though it probably should only be exposed via a JS/envvar option, not a CLI flag, since I doubt it would be commonly used. Not sure how easy it would be to implement, but is seems to me like the default k6 behavior shouldn't be to cache everything indefinitely, but to respect the TTL setting of DNS records... As @paulgrav mentions in the issue title, the current behavior may definitely be unexpected to users. |
Thanks for acknowledging this. Respecting the TTL would be ideal. Overriding the DNS caching via envvar would be better than the current hardcoded indefinite cache time. |
Looking into what it would take to do this. Here's the situation:
I propose to handle this by adding TTL support to an existing quality package then replacing the current resolver with that package.
|
I'm not familiar with |
OK, perfect. |
Started a submission to |
The |
Realized something else is necessary. I have a question in with |
I'm not hearing back from dnsr. They have their own efforts taking attention. What would you guys think about forking dnsr and publishing a loadimpact resolver? There does seem to be a need for it. Had trouble finding a decent one when I did that search. The license is MIT. I have a tested patch for this final feature ready to submit. |
I'd prefer that we avoid forking a project that's at least somewhat active... Given the way Go imports are specified by URLs, it's a bit of a PITA to temporarily fork a repo. I'm not sure if it would be better after #1070, but for now it's probably not worth it. I haven't delved into the dnsr code or your patches there yet, but does your latest patch need to be in the repo itself? Can it work as a helper function in the k6 repo as a temporary workaround? |
Alright. I'll try pinging dnsr, maybe they just haven't seen it. Tried to find something external first, but I don't think there's a way. It needs to use cache in a new way. The cache field is private so (I think?) there's no way to get at it from outside. |
Opened a preliminary submission for this #1085. Turned out there are a few things dnsr doesn't quite do. I've built around it to try to handle them. It puts more resolution logic outside the resolver than I really wanted. Won't blame you if you don't want it. But at least it gives you the option. Maybe things can be moved into the resolver over time. |
Thanks! I'll take a thorough look tomorrow or early next week. |
Hi! Would this by any chance be available on 0.26? I'm experiencing it on a round-robin internal domain managed by route 53, TTLs aren't respected to a single node ends receiving all of the traffic from k6. |
@gabrielqs, sorry for the late response 😞 Unfortunately these fixes won't be in k6 v0.26.0, since we're in the final stages of testing and hoping to publicly release it by the end of this week. We're aiming to have all of the DNS fixes be part of the next k6 release though, so watch this space for updates! For context, the delay with fixing the DNS issues stems from the lack of suitable DNS resolving and caching libraries for our use cases in k6, so we basically had to write one, starting from a lower-level than expected... |
@na-- thanks for the info! |
This more or less reproduces the scenario described in grafana#726.
This more or less reproduces the scenario described in grafana#726.
While working on #1612 I stumbled upon this project: https://github.com/ncruces/go-dns It's a very lightweight implementation of custom resolvers that works by overriding If we need an abstraction for DNS messages, we could also use https://godoc.org/golang.org/x/net/dns/dnsmessage instead of |
I’d better like to understand K6s behaviour in relation to DNS caching.
I’m trying to run tests against a couple of load balanced K8S clusters. The failover is managed by a traffic manager so once the traffic manager has detected a failure in one of the clusters it will update the DNS records so that traffic only hits the healthy cluster. I’ve tried to reduce the problem, described below.
Steps to reproduce:
host.name
points to a CNAME that returns HTML and has a TTL of 60s.host.name
to a domain that doesn’t resolve e.g.,foo.bar.asdf
Actual results:
All HTTP calls in the test succeed despite the CNAME record being changed to point to a domain that doesn’t resolve.
Expected results:
After 60s but before the test ends, there should be some test failures because the HTTP requests fail.
The text was updated successfully, but these errors were encountered: