Skip to content

[serve][release] Decode Locust worker payload before sending it - #67220

Merged
elliot-barn merged 1 commit into
masterfrom
elliot-barn/fix-locust-payload
Oct 27, 2026
Merged

elliot-barn merged 1 commit into
masterfrom
elliot-barn/fix-locust-payload

Conversation

@elliot-barn

Copy link
Copy Markdown
Collaborator

Why

pytest_serve_autoscaling_load_test has been sending a bad payload on every request, and the test hid it.

release/serve_tests/workloads/locust_utils.py hands the worker subprocess its payload as a JSON string in sys.argv[1]. The worker passed that string straight to json=, so locust encoded it a second time. Every request body was a JSON string ("{\"uri\": ...}"). resnet_50.py then failed on (await request.json())["uri"] with TypeError: string indices must be integers and returned HTTP 500 on 100% of requests.

Master's nightly still passes because of a second bug:

  • run_locust_worker raises only if client.errors is non-empty, and autoscaling_load_test.py never checks the failure rate.
  • On the ray-ml image (locust==2.18.0), the request listener crashes on response.text. Serve's 500 response declares no charset, and locust 2.18 calls str(content, None), which raises TypeError: str() argument 'encoding' must be str, not None.
  • Locust catches handler exceptions and only logs them, so the error is never appended and the test passes.

Master's nightly build 111411 shows 1,901,821 requests and 1,901,821 failures, and the test still passed.

Locust 2.39 (in the ray-torch image) falls back to detecting the encoding, so the errors are recorded and the worker raises. That's how this surfaced while moving the test to ray-torch in #66880.

Change

Decode sys.argv[1] with json.loads in the worker script, so the request body is the original {"uri": ...} object.

replica_scalability.py also uses this helper, with data=None. It now sends no body instead of "null", which makes no difference to its noop app.

With this fix the autoscaling test sends real ResNet inference load again, so expect its latency and RPS metrics to change.

Duplicate check

I searched open PRs for locust and autoscaling_load_test and found nothing related.

Testing

  • Confirmed the root cause in the service's replica logs (TypeError at resnet_50.py:38) and the masked errors in master's job logs (repeated "Uncaught exception in event handler").
  • Checked the round-trip locally: the old body is "{\"uri\": \"x\"}", the new body is {"uri": "x"}.
  • pre-commit passed.
  • I haven't run a release test with the fix yet. Filter:
name:^pytest_serve_autoscaling_load_test\.aws$
name:^pytest_serve_autoscaling_load_test\.aws\.haproxy$

AI assistance (Claude Code) was used to investigate and write this change.

🤖 Generated with Claude Code

The Locust worker subprocess received the request payload as a JSON string
in argv and passed it straight to json=, so every request body was a JSON
string literal and resnet_50.py failed on request.json()["uri"] with a
TypeError (HTTP 500 on 100% of requests).

On the ray-ml image (locust 2.18) the request listener crashed on
response.text with a None encoding before recording the error, so the test
passed despite every request failing. Newer locust (2.39, in the ray-torch
image) records the errors and run_locust_worker raises.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: elliot-barn <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates release/serve_tests/workloads/locust_utils.py to parse the first command-line argument as a JSON object using json.loads instead of a raw string. There are no review comments, and I have no feedback to provide.

@ray-gardener ray-gardener Bot added serve Ray Serve Related Issue release-test release test labels Oct 26, 2026
@elliot-barn
elliot-barn requested a review from a team October 27, 2026 00:05

@qishengxhe qishengxhe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this should fix the payload. I'll send a quick followup on the test not failing on request errors, which not a release blocker

@elliot-barn elliot-barn added the go add ONLY when ready to merge, run all tests label Oct 27, 2026
@elliot-barn
elliot-barn enabled auto-merge (squash) October 27, 2026 00:26
@elliot-barn
elliot-barn merged commit 47328ea into master Oct 27, 2026
7 checks passed
@elliot-barn
elliot-barn deleted the elliot-barn/fix-locust-payload branch October 27, 2026 01:21
justinyeh1995 pushed a commit to justinyeh1995/ray that referenced this pull request Oct 28, 2026
…project#67220)

## Why

`pytest_serve_autoscaling_load_test` has been sending a bad payload on
every request, and the test hid it.

`release/serve_tests/workloads/locust_utils.py` hands the worker
subprocess its payload as a JSON string in `sys.argv[1]`. The worker
passed that string straight to `json=`, so locust encoded it a second
time. Every request body was a JSON *string* (`"{\"uri\": ...}"`).
`resnet_50.py` then failed on `(await request.json())["uri"]` with
`TypeError: string indices must be integers` and returned HTTP 500 on
100% of requests.

Master's nightly still passes because of a second bug:

- `run_locust_worker` raises only if `client.errors` is non-empty, and
`autoscaling_load_test.py` never checks the failure rate.
- On the ray-ml image (`locust==2.18.0`), the request listener crashes
on `response.text`. Serve's 500 response declares no charset, and locust
2.18 calls `str(content, None)`, which raises `TypeError: str() argument
'encoding' must be str, not None`.
- Locust catches handler exceptions and only logs them, so the error is
never appended and the test passes.

Master's nightly build 111411 shows 1,901,821 requests and 1,901,821
failures, and the test still passed.

Locust 2.39 (in the ray-torch image) falls back to detecting the
encoding, so the errors are recorded and the worker raises. That's how
this surfaced while moving the test to ray-torch in ray-project#66880.

## Change

Decode `sys.argv[1]` with `json.loads` in the worker script, so the
request body is the original `{"uri": ...}` object.

`replica_scalability.py` also uses this helper, with `data=None`. It now
sends no body instead of `"null"`, which makes no difference to its noop
app.

With this fix the autoscaling test sends real ResNet inference load
again, so expect its latency and RPS metrics to change.

## Duplicate check

I searched open PRs for `locust` and `autoscaling_load_test` and found
nothing related.

## Testing

- Confirmed the root cause in the service's replica logs (`TypeError` at
`resnet_50.py:38`) and the masked errors in master's job logs (repeated
"Uncaught exception in event handler").
- Checked the round-trip locally: the old body is `"{\"uri\": \"x\"}"`,
the new body is `{"uri": "x"}`.
- pre-commit passed.
- I haven't run a release test with the fix yet. Filter:

```
name:^pytest_serve_autoscaling_load_test\.aws$
name:^pytest_serve_autoscaling_load_test\.aws\.haproxy$
```

AI assistance (Claude Code) was used to investigate and write this
change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: elliot-barn <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
elliot-barn added a commit that referenced this pull request Oct 30, 2026
…2/N) (#67262)

Stacked on #66880 (step 1/N). Review only the top commit until #66880
merges.

## Why

This is step 2 of retiring the `anyscale/ray-ml` image from release
tests. It moves the data release tests to the ray-torch image
(`torch-cu128`) on Python 3.11, the same target #66880 uses.

## Change

- The `DEFAULTS` block in `release/release_data_tests.yaml` switches
from `type: gpu` (ray-ml) to `type: torch-cu128`.
`training_ingest_regression_test` set `type: gpu` explicitly and
switches too.
- 47 test entries move from `python: "3.10"` to `"3.11"`.
- Two tests need packages ray-torch doesn't ship, so they get
`python_depset`s. Like the #66880 depsets, these are expanded from
`ray-torch-cu128_base_py3.11.lock` and constrained to it. I diffed each
lock against the image lock: both only add packages and change no
existing pin.
- `read_tfrecords` and `to_tf` get
`torch_cu128_data_tensorflow_py3.11.lock`, which adds tensorflow 2.19.1
and tensorflow-metadata 1.17.3. tensorflow 2.20 needs `protobuf>=5.28`,
and the image pins 5.27.5.
- `image_embedding_from_uris_*` and `image_embedding_from_jsonl_*` get
`torch_cu128_data_image_embedding_py3.11.lock`, which adds
albumentations 2.0.8 and pybase64 1.4.3.
- The deltalake and pyiceberg `post_build_script`s are unchanged.
Neither package touches torch or numpy.

**Still on ray-ml, each with a TODO (follow-up):**
- `image_classification_fixed_size` and
`image_classification_from_parquet_fixed_size` pin `pyarrow==19` through
`image_classification_py3.10.lock`, because the dataset uses the removed
`pyarrow.PyExtensionType`. ray-torch ships pyarrow 23. These need a
data-team fix to the dataset.
- `distributed_training` imports `mosaicml-streaming` at module load,
even though this test never uses `--use-mosaic`. Every streaming release
needs torchtext (0.5.x, which pins an old torch) or `transformers<5`
(0.6 through 0.13). Both conflict with ray-torch's torch 2.10 and
transformers 5.11. Making the import lazy would unblock it.

`text_embedding_*` already uses `cu123` and is unchanged.

## Release test filter

```
name:^(read_parquet_fixed_size|read_large_parquet_fixed_size|read_images_fixed_size|read_tfrecords|read_from_uris_fixed_size|write_parquet|write_delta|write_delta_smoke|write_delta_overwrite|write_delta_partitioned|iceberg_benchmark_[^.]+|iceberg_benchmark_overwrite|aggregate_groups_low_cardinality|aggregate_groups_high_cardinality|map_groups_high_cardinality|map_groups_low_cardinality|joins_[^.]+_[^.]+|joins_[^.]+_[^.]+_disk|wide_schema_pipeline_primitives|wide_schema_pipeline_tensors|wide_schema_pipeline_objects|wide_schema_pipeline_nested_structs|streaming_split|mix|training_ingest_benchmark|training_ingest_regression_test|chunked_tensor_take|iter_batches_[^.]+|iter_batches_pyarrow|to_tf|iter_torch_batches|map|flat_map|map_batches_fixed_size_[^.]+_[^.]+_[^.]+|worker_scaling_[^.]+_[^.]+_[^.]+ops|backpressure_fast_producer_slow_consumer|backpressure_many_tiny_objects|backpressure_training_prefetch|backpressure_heterogeneous_memory_nodes|random_shuffle|heterogeneous_memory_batch_inference_multitenancy|image_embedding_from_uris_[^.]+|image_embedding_from_jsonl_[^.]+|multi_stage_batch_inference|tpch_[^.]+|tpch_[^.]+_disk_shuffle)(\..+)?$
```

## Duplicate check

I searched open PRs for ray-ml / ray-torch data release test changes.
Only #66880 (step 1, which this stacks on) and #67220 (a serve test fix)
came up.

## Testing

- `bazel test //release:test_config //release:test_test` passes.
- `bazel run //ci/raydepsets:raydepsets -- build --all-configs --check`
passes.
- pre-commit passes.
- The release tests haven't run on this branch yet. The filter is above.

AI assistance (Claude Code) was used to make and check this change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: elliot-barn <[email protected]>
Signed-off-by: Elliot Barnwell <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests release-test release test serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants