Allow setting the http1.1 flag from the restate operator#38
Conversation
| 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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
| /// Optional configuration options for service registration | ||
| class Options { | ||
| /// Force the use of HTTP/1.1 when registering with Restate | ||
| useHttp1: Boolean? |
There was a problem hiding this comment.
I think it should be called useHttp11 to match the restate api, and it can be top level in the restate object, imo
There was a problem hiding this comment.
Alright. I moved the flag to root and removed the options parent from everywhere.
Co-authored-by: Jack Kleeman <jackkleeman@gmail.com>
|
Thanks! |


Builds upon #37