Closed austin3dickey closed 1 year ago
Could not reproduce locally yet.
from datetime import datetime
import os
from benchclients import ConbenchClient
os.environ["CONBENCH_URL"] = "https://127.0.0.1:5000"
os.environ["CONBENCH_EMAIL"] = "e@e.com"
os.environ["CONBENCH_PASSWORD"] = "test"
client = ConbenchClient()
client.post(
"/benchmark-results",
{
"batch_id": "test",
"context": {},
"info": {},
"run_id": "test",
"tags": {"name": "test"},
"timestamp": datetime.now().isoformat(),
"cluster_info": {"name": "test", "info": {}, "optional_info": {}},
"error": {},
},
)
230606-10:20:49.113 INFO: try to perform login
230606-10:20:49.113 INFO: try: POST to http://127.0.0.1:5000/api/login/
230606-10:20:49.194 INFO: POST request to http://127.0.0.1:5000/api/login/: took 0.0805 s, response status code: 204
230606-10:20:49.194 INFO: ConbenchClient: initialized
230606-10:20:49.194 INFO: try: POST to http://127.0.0.1:5000/api/benchmark-results/
230606-10:20:49.208 INFO: POST request to http://127.0.0.1:5000/api/benchmark-results/: took 0.0142 s, response status code: 201
@jgehrcke pointed out that we are receiving a JSON array at the end of the logs; that is, we are probably being wrongly redirected to the GET /benchmark-results
endpoint instead. I suspect the reason I can't reproduce locally is that it's not using HTTPS.
we are probably being wrongly redirected to the
GET /benchmark-results
endpoint instead
Notably we're getting a list of results—this is the GET list endpoint, not the GET BenchmarkListAPI
(not BenchmarkEntityAPI
) even though it doesn't take a list because the endpoint is /api/benchmark-results
, not /api/benchmark-results/<id>
. Which I guess is fine, but BenchmarkListAPI
is a bad name. (Also maybe we should accept a list of results in a single call, but that's another discussion.)
Not an answer, but maybe helpful for localizing the problem
we are probably being wrongly redirected to the GET /benchmark-results endpoint instead. I suspect the reason I can't reproduce locally is that it's not using HTTPS.
What's happening is probably what I described in https://github.com/conbench/conbench/pull/1150#issuecomment-1518624190:
Flask emits a 308 redirect response with the idea to add the trailing slash, but it also sets the scheme to HTTP ALB sees HTTP scheme and is configured to emit a 301 redirect response for the HTTP->HTTPS redirect
Client then sees the 301 redirect and switches method to GET (which is what 301 demands, by standard -- the 308 would allow for the method to stay the same).
BenchmarkListAPI is a bad name
Yes. In RESTy terminology this is a "collection" (this is the better term, and I think "list" tried to be that). It's typical to
Something with BenchmarkResultCollection
would be a better name :)
Indeed, I tried the same script, using credentials for our staging environment, and turned up the verbosity of urllib3
logging. Here's the result:
230606-10:28:11.753 INFO: try to perform login
230606-10:28:11.753 INFO: try: POST to https://<staging>/api/login/
230606-10:28:11.846 DEBUG: Starting new HTTPS connection (1): <staging>:443
230606-10:28:12.152 DEBUG: https://<staging>:443 "POST /api/login/ HTTP/1.1" 204 0
230606-10:28:12.153 INFO: POST request to https://<staging>/api/login/: took 0.3994 s, response status code: 204
230606-10:28:12.153 INFO: ConbenchClient: initialized
230606-10:28:12.153 INFO: try: POST to https://<staging>/api/benchmark-results
230606-10:28:12.187 DEBUG: https://<staging>:443 "POST /api/benchmark-results HTTP/1.1" 308 299
230606-10:28:12.190 DEBUG: Starting new HTTP connection (1): <staging>:80
230606-10:28:12.240 DEBUG: http://<staging>:80 "POST /api/benchmark-results/ HTTP/1.1" 301 134
230606-10:28:12.453 DEBUG: https://<staging>:443 "GET /api/benchmark-results/ HTTP/1.1" 200 74641
230606-10:28:12.504 INFO: POST request to https://<staging>/api/benchmark-results: took 0.3505 s, response status code: 200
230606-10:28:12.504 INFO: unexpected response. code: 200, body bytes: <[
{
"id": "0647f3a122467d4880007fbbb90a1c83",
"run_id": "e5ee699260464d039baeebd326b77de8",
"batch_id": "dba73b4db49e4e2bb819bd087f446eac",
"timestamp": "2023-06-06T13:52:16Z",
"tags": {
"name": "tpch-theseus",
"ptds": "False",
"query_id": "TPCH-01",
"multi_nics": "disabled",
"scale_factor": "1",
"dataset_variant": "parquet-float64",
...>
Traceback (most recent call last):
File "/Users/austin/Desktop/asd.py", line 14, in <module>
client.post(
File "/Users/austin/repos/conbench/benchclients/python/benchclients/http.py", line 164, in post
resp = self._make_request("POST", self._abs_url_from_path(path), 201, json=json)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/austin/repos/conbench/benchclients/python/benchclients/http.py", line 205, in _make_request
result = self._make_request_retry_until_deadline(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/austin/repos/conbench/benchclients/python/benchclients/http.py", line 266, in _make_request_retry_until_deadline
result = self._make_request_retry_guts(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/austin/repos/conbench/benchclients/python/benchclients/http.py", line 393, in _make_request_retry_guts
raise RetryingHTTPClientNonRetryableResponse(message=msg, error_response=resp)
benchclients.http.RetryingHTTPClientNonRetryableResponse: POST request to https://<staging>/api/benchmark-results: unexpected HTTP response. Expected code 201, got 200. Leading bytes of body: <[
{
"id": "0647f3a122467d4880007fbbb90a1c83",
"run_id": "e5ee699260464d039baeebd326b77de8",
"batch_id": "dba73b4db49e4e2bb819bd087f446ea ...>
So this happens:
POST https://<staging>/api/benchmark-results
. Receive 308 PERMANENT REDIRECT
with Location: http://<staging>/api/benchmark-results/
POST http://<staging>/api/benchmark-results/
. Receive 301 Moved Permanently
with Location: https://<staging>:443/api/benchmark-results/
GET https://<staging>:443/api/benchmark-results/
. Receive 200 OK
with the wrong data.This is heavily related to https://github.com/conbench/conbench/issues/1151. As we did before, we can temporarily solve it by adding a trailing slash to the URL path. I validated that this works locally.
and turned up the verbosity of urllib3 logging. Here's the result:
nice! :heart:
This did work. Now we're getting green builds again! https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/2987#01889168-ac0a-476c-bedd-b243a0a821e7/33-5400
[230606-16:43:20.389] [2043828] [benchclients.http] INFO: POST request to https://conbench.ursa.dev/api/benchmark-results/: took 0.0432 s, response status code: 201
Example build: https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-m5-4xlarge-us-east-2/builds/2347#018890c5-5406-469b-a411-3495092d1fe5