-
Notifications
You must be signed in to change notification settings - Fork 851
Serve stale content when DNS lookup fails #8484
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| `` | ||
| > GET / HTTP/1.1 | ||
| > Host: `` | ||
| > User-Agent: curl/`` | ||
| > Accept: */* | ||
| `` | ||
| < HTTP/1.1 200 OK | ||
| < Server: ATS`` | ||
| < Accept-Ranges: bytes | ||
| < Content-Length: 6 | ||
| < Cache-Control: public, max-age=5 | ||
| < Expires: `` | ||
| < Age: `` | ||
| < Date: `` | ||
| < Connection: keep-alive | ||
| `` | ||
| > GET / HTTP/1.1 | ||
| > Host: `` | ||
| > User-Agent: curl/`` | ||
| > Accept: */* | ||
| `` | ||
| < HTTP/1.1 500 Cannot find server. | ||
| < Date: `` | ||
| < Server: ATS`` | ||
| < Cache-Control: no-store | ||
| < Content-Type: `` | ||
| < Content-Language: `` | ||
| < Content-Length: `` | ||
| < Connection: keep-alive | ||
| `` | ||
| > GET / HTTP/1.1 | ||
| > Host: `` | ||
| > User-Agent: curl/`` | ||
| > Accept: */* | ||
| `` | ||
| < HTTP/1.1 200 OK | ||
| < Server: ATS`` | ||
| < Accept-Ranges: bytes | ||
| < Content-Length: 6 | ||
| < Cache-Control: public, max-age=5 | ||
| < Age: `` | ||
| < Date: `` | ||
| < Connection: keep-alive | ||
| `` | ||
| > GET / HTTP/1.1 | ||
| > Host: `` | ||
| > User-Agent: curl/`` | ||
| > Accept: */* | ||
| `` | ||
| < HTTP/1.1 500 Cannot find server. | ||
| < Date: `` | ||
| < Server: ATS`` | ||
| < Cache-Control: no-store | ||
| < Content-Type: `` | ||
| < Content-Language: `` | ||
| < Content-Length: `` | ||
| `` |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,79 @@ | ||||
| ''' | ||||
| Test proxy serving stale content when DNS lookup fails | ||||
| ''' | ||||
| # Licensed to the Apache Software Foundation (ASF) under one | ||||
| # or more contributor license agreements. See the NOTICE file | ||||
| # distributed with this work for additional information | ||||
| # regarding copyright ownership. The ASF licenses this file | ||||
| # to you under the Apache License, Version 2.0 (the | ||||
| # "License"); you may not use this file except in compliance | ||||
| # with the License. You may obtain a copy of the License at | ||||
| # | ||||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||||
| # | ||||
| # Unless required by applicable law or agreed to in writing, software | ||||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| # See the License for the specific language governing permissions and | ||||
| # limitations under the License. | ||||
|
|
||||
| Test.ContinueOnFail = True | ||||
| # Set up hierarchical caching processes | ||||
| ts_child = Test.MakeATSProcess("ts_child") | ||||
| ts_parent = Test.MakeATSProcess("ts_parent") | ||||
| server_name = "http://unknown.domain.com/" | ||||
|
|
||||
| Test.testName = "STALE" | ||||
|
|
||||
| # Config child proxy to route to parent proxy | ||||
| ts_child.Disk.records_config.update({ | ||||
| 'proxy.config.url_remap.pristine_host_hdr': 1, | ||||
| 'proxy.config.http.cache.max_stale_age': 10, | ||||
| 'proxy.config.http.parent_proxy.self_detect': 0, | ||||
| }) | ||||
| ts_child.Disk.parent_config.AddLine( | ||||
| f'dest_domain=. parent=localhost:{ts_parent.Variables.port} round_robin=consistent_hash go_direct=false' | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So even with this configured, child TS will still do a DNS lookup on unkown.domain.com ? Did you see the DNS lookup in the http debug trace output?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The http debug trace output shows the child doing PPDNS lookup to the parent and the parent doing a DNS lookup to unknown.domain.com (OS). After the DNS lookup fails for the parent but the parent has the stale returnable object in its cache, the child will revalidate from the parent (without doing a DNS lookup) and return the object to the client. Let me know if you are seeing something different in the debug trace output!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lately we've been including DNS servers in our Au tests:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why ATS would do a DNS lookup on the request host when it's not using the request host as the next hop. But I suppose that's beyond the scope of this PR. |
||||
| ) | ||||
| ts_child.Disk.remap_config.AddLine( | ||||
| f'map http://localhost:{ts_child.Variables.port} {server_name}' | ||||
| ) | ||||
|
|
||||
| # Configure parent proxy | ||||
| ts_parent.Disk.records_config.update({ | ||||
| 'proxy.config.url_remap.pristine_host_hdr': 1, | ||||
| 'proxy.config.http.cache.max_stale_age': 10, | ||||
| }) | ||||
| ts_parent.Disk.remap_config.AddLine( | ||||
| f'map http://localhost:{ts_parent.Variables.port} {server_name}' | ||||
| ) | ||||
| ts_parent.Disk.remap_config.AddLine( | ||||
| f'map {server_name} {server_name}' | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am testing for non-hierarchical scenarios as well so the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively you can also do:
But the way you have it is fine. |
||||
| ) | ||||
|
|
||||
| # Object to push to proxies | ||||
| stale_5 = "HTTP/1.1 200 OK\nServer: ATS/10.0.0\nAccept-Ranges: bytes\nContent-Length: 6\nCache-Control: public, max-age=5\n\nCACHED" | ||||
| stale_10 = "HTTP/1.1 200 OK\nServer: ATS/10.0.0\nAccept-Ranges: bytes\nContent-Length: 6\nCache-Control: public, max-age=10\n\nCACHED" | ||||
|
|
||||
|
|
||||
| # Testing scenarios | ||||
| child_curl_request = ( | ||||
| # Test child serving stale with failed DNS OS lookup | ||||
| f'curl -X PUSH -d "{stale_5}" "http://localhost:{ts_child.Variables.port}";' | ||||
| f'curl -X PUSH -d "{stale_10}" "http://localhost:{ts_parent.Variables.port}";' | ||||
| f'sleep 7; curl -s -v http://localhost:{ts_child.Variables.port};' | ||||
| f'sleep 15; curl -s -v http://localhost:{ts_child.Variables.port};' | ||||
| # Test parent serving stale with failed DNS OS lookup | ||||
| f'curl -X PUSH -d "{stale_5}" "http://localhost:{ts_parent.Variables.port}";' | ||||
| f'sleep 7; curl -s -v http://localhost:{ts_parent.Variables.port};' | ||||
| f'sleep 15; curl -s -v http://localhost:{ts_parent.Variables.port};' | ||||
| ) | ||||
|
|
||||
| # Test case for when parent server is down but child proxy can serve cache object | ||||
| tr = Test.AddTestRun() | ||||
| tr.Processes.Default.Command = child_curl_request | ||||
| tr.Processes.Default.ReturnCode = 0 | ||||
| tr.Processes.Default.StartBefore(ts_child) | ||||
| tr.Processes.Default.StartBefore(ts_parent) | ||||
| tr.Processes.Default.Streams.stderr = "gold/serve_stale_dns_fail.gold" | ||||
| tr.StillRunningAfter = ts_child | ||||
| tr.StillRunningAfter = ts_parent | ||||
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.
Most of our Au tests don't assigned testName, I'm not sure what it's for: