Http tap filter on big response body: only tapped a small part
Description:
Describe the issue.
Hi, I'm testing the HTTP tap filter locally. For small response it is working nicely, but my job needs to handle big response, so I did a simple local test. The result seems show only a small part of response body is tapped, which shouldn't be. Here is how I tested.
python server
# Python 3 server example
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
hostName = "localhost"
serverPort = 22220
big_str = "8"*(1000*1000*1000) # 1GB response
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(bytes("<html><head><title>https://pythonbasics.org</title></head>", "utf-8"))
self.wfile.write(bytes("<p>Request: %s</p>" % self.path, "utf-8"))
self.wfile.write(bytes("<body>", "utf-8"))
self.wfile.write(bytes(f"<p>This is an example web server. {big_str} </p>", "utf-8"))
self.wfile.write(bytes("</body></html>", "utf-8"))
if __name__ == "__main__":
webServer = HTTPServer((hostName, serverPort), MyServer)
print("Server started http://%s:%s" % (hostName, serverPort))
try:
webServer.serve_forever()
except KeyboardInterrupt:
pass
webServer.server_close()
print("Server stopped.")
envoy config
Notice that I used streaming and I tried all PROTO_* format but all don't work out.
static_resources:
listeners:
- name: listener_0
address:
socket_address:
address: 0.0.0.0
port_value: 10001
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
access_log:
- name: envoy.access_loggers.stdout
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
http_filters:
- name: envoy.filters.http.tap
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.tap.v3.Tap
common_config:
static_config:
match_config:
any_match: true
output_config:
streaming: true
sinks:
- format: PROTO_TEXT
file_per_tap:
path_prefix: /tmp/any/
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
route_config:
name: local_route
virtual_hosts:
- name: local_big_resp
domains: ["local_big"]
routes:
- match:
prefix: "/"
route:
cluster: local_big
clusters:
- name: local_big
connect_timeout: 5s
load_assignment:
cluster_name: local_big
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 22220
curl
curl -s --http1.1 -o dump.log localhost:10001 \
-H "Host: local_big" \
compare the curl dump v.s. tap result
As you can see, the tap result file is much much smaller than the real response.
-rw-r--r-- 1 xianggao staff 954M May 7 20:30 dump.log
-rw-r--r-- 1 xianggao wheel 1.1M May 7 20:30 _6671696024908614325.pb_text
I wonder if I did something wrong for tapping big response? Or maybe tapping to file is not suitable, and tapping to another service is better? Thanks for your help!
[optional Relevant Links:]
Any extra documentation required to understand the issue.
cc: @mattklein123 @daixiang0
/cc @xu1zhou
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.