Skip to content

Allow setting the http1.1 flag from the restate operator#38

Merged
jackkleeman merged 4 commits into
restatedev:mainfrom
minimistapp:f/use-http1.1
Jul 30, 2025
Merged

Allow setting the http1.1 flag from the restate operator#38
jackkleeman merged 4 commits into
restatedev:mainfrom
minimistapp:f/use-http1.1

Conversation

@damianr13

Copy link
Copy Markdown
Contributor

Builds upon #37

hasher.write(service_path.as_bytes());
}

// if you change the HTTP version option, it creates a new deployment, which means we want a new replicaset too to keep things 1:1

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.

can you check if this is true? i'm concerned that it doesnt actually make a new deployment id so we'd end up with two replicasets sharing a deployment id

@damianr13 damianr13 Jul 29, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is what I am getting when I register a hypercorn app (that supports both HTTP/1.1 and HTTP/2) with different values for that flag

> curl -L 'http://localhost:9070/deployments' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
  "uri": "http://host.docker.internal:9001",
  "use_http_11": false
}'
{"id":"dp_13DAjaCfAoAxPMzAZ0uBnI5","services":[{"name":"CheckoutService","handlers":[{"name":"handle","ty":"Shared","public":true,"input_description":"application/json","output_description":"JSON boolean","input_json_schema":true,"output_json_schema":{"type":"boolean"}}],"ty":"Service","deployment_id":"dp_13DAjaCfAoAxPMzAZ0uBnI5","revision":1,"public":true,"idempotency_retention":"1d"},{"name":"CartObject","handlers":[{"name":"addTicket","ty":"Exclusive","public":true,"input_description":"JSON string","output_description":"JSON boolean","input_json_schema":{"type":"string"},"output_json_schema":{"type":"boolean"}},{"name":"checkout","ty":"Exclusive","public":true,"input_description":"none","output_description":"JSON boolean","output_json_schema":{"type":"boolean"}},{"name":"expireTicket","ty":"Exclusive","public":true,"input_description":"JSON string","output_description":"none","input_json_schema":{"type":"string"}}],"ty":"VirtualObject","deployment_id":"dp_13DAjaCfAoAxPMzAZ0uBnI5","revision":1,"public":true,"idempotency_retention":"1d"},{"name":"TicketObject","handlers":[{"name":"reserve","ty":"Exclusive","public":true,"input_description":"application/json","output_description":"JSON boolean","input_json_schema":true,"output_json_schema":{"type":"boolean"}},{"name":"unreserve","ty":"Exclusive","public":true,"input_description":"application/json","output_description":"none","input_json_schema":true},{"name":"markAsSold","ty":"Exclusive","public":true,"input_description":"application/json","output_description":"none","input_json_schema":true}],"ty":"VirtualObject","deployment_id":"dp_13DAjaCfAoAxPMzAZ0uBnI5","revision":1,"public":true,"idempotency_retention":"1d"}],"min_protocol_version":5,"max_protocol_version":5,"sdk_version":"restate-sdk-python/0.7.0"}
> curl -L 'http://localhost:9070/deployments' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
  "uri": "http://host.docker.internal:9001",
  "use_http_11": true
}'
{"id":"dp_15HZMTNDV7FVPWIdhDuO8zT","services":[{"name":"TicketObject","handlers":[{"name":"markAsSold","ty":"Exclusive","public":true,"input_description":"application/json","output_description":"none","input_json_schema":true},{"name":"unreserve","ty":"Exclusive","public":true,"input_description":"application/json","output_description":"none","input_json_schema":true},{"name":"reserve","ty":"Exclusive","public":true,"input_description":"application/json","output_description":"JSON boolean","input_json_schema":true,"output_json_schema":{"type":"boolean"}}],"ty":"VirtualObject","deployment_id":"dp_15HZMTNDV7FVPWIdhDuO8zT","revision":2,"public":true,"idempotency_retention":"1d"},{"name":"CheckoutService","handlers":[{"name":"handle","ty":"Shared","public":true,"input_description":"application/json","output_description":"JSON boolean","input_json_schema":true,"output_json_schema":{"type":"boolean"}}],"ty":"Service","deployment_id":"dp_15HZMTNDV7FVPWIdhDuO8zT","revision":2,"public":true,"idempotency_retention":"1d"},{"name":"CartObject","handlers":[{"name":"expireTicket","ty":"Exclusive","public":true,"input_description":"JSON string","output_description":"none","input_json_schema":{"type":"string"}},{"name":"addTicket","ty":"Exclusive","public":true,"input_description":"JSON string","output_description":"JSON boolean","input_json_schema":{"type":"string"},"output_json_schema":{"type":"boolean"}},{"name":"checkout","ty":"Exclusive","public":true,"input_description":"none","output_description":"JSON boolean","output_json_schema":{"type":"boolean"}}],"ty":"VirtualObject","deployment_id":"dp_15HZMTNDV7FVPWIdhDuO8zT","revision":2,"public":true,"idempotency_retention":"1d"}],"min_protocol_version":5,"max_protocol_version":5,"sdk_version":"restate-sdk-python/0.7.0"}

There are different deployment ids associated with the 2 calls.

I can also see 2 deployments in the UI.
image

@damianr13 damianr13 Jul 29, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[Update] it was confusing that the 2 deployments had consecutive revision numbers, but if I call the API a bunch of times with the 2 different json bodies, the revision versions can diverge, they are not linked

image

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.

I think those are showing up as separate deployments because the http2 server is advertising itself as supporting restate's bidirectional protocol, and the http1.1 server isn't. The logic in restate to dedupe deployments is based on url and protocol type, but not based on http version. in other sdks its possible that you could switch the http1.1 flag off and re-register and get the same deployment id.

However, I think with what you've done in this PR, ie force the replicaset name to change if the flag changes, its ok. The new url will guarantee a new deployment id. All we need to do is fix the comment to something like:
It's possible that changing this flag will create a new deployment id; by making it part of the replicaset name we guarantee that deployments and replicasets stay 1:1

damianr13 and others added 2 commits July 29, 2025 14:56
Adds an optional 'useHttp1' field under spec.restate.options that allows
forcing HTTP/1.1 when registering services with Restate, similar to the
--use-http1.1 CLI flag.

Changes:
- Add RestateOptions struct with useHttp1 field to RestateSpec
- Update controller to pass useHttp1 option in registration payload
- Include useHttp1 option in pod template hash calculation
- Update CRD definitions and documentation
- Add example deployment manifest with options

Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s93345690fcc86468k
Comment thread crd/RestateDeployment.pkl Outdated
/// Optional configuration options for service registration
class Options {
/// Force the use of HTTP/1.1 when registering with Restate
useHttp1: Boolean?

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.

I think it should be called useHttp11 to match the restate api, and it can be top level in the restate object, imo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Alright. I moved the flag to root and removed the options parent from everywhere.

Comment thread src/controllers/restatedeployment/reconcilers/replicaset.rs Outdated
Co-authored-by: Jack Kleeman <jackkleeman@gmail.com>
@jackkleeman
jackkleeman merged commit 282f767 into restatedev:main Jul 30, 2025
1 check passed
@jackkleeman

Copy link
Copy Markdown
Contributor

Thanks!

@github-actions github-actions Bot locked and limited conversation to collaborators Jul 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants