GoogleCloudPlatform / GoogleCloudPlatform/esp-v2
HTTP endpoint with google.api.http annotation doesn't transcode locally
- Dominant language
- Go
- Stars
- 307
- Forks
- 185
- Avg merge
- 14h 45m
- Merged PRs (30d)
- 6
Description
Hello there! I’m running into an issue when locally testing an ESPv2 endpoint deployed in docker when using http endpoints. We use this setup frequently for app/web based gRPC client testing with no issue. This is the first time we are using the google.api.http annotation to define http endpoints though. Everything works as expected in Postman when accessing the endpoint via secure gRPC or the GRPC_SERVICE_FULL_NAME/METHOD_NAME. No errors and the backend node container receives the request. However, when accessing via the http path (ex /v1/generate), we get a 404 error. No errors in Envoy (ESPv2) but hard to tell where its failing. This works as intended in production with the reverse-proxy image and the endpoint does indeed get transposed to the GRPC_SERVICE_FULL_NAME/METHOD_NAME. However with the sidecar image locally the request passes through envoy as `/v1/generate` and doesnt get matched to the handler causing a 404.
HTTP POST https://localhost:8080/cfg.main.v1.MainService/Generate (works)
gRPC grpcs://localhost:8080 Generate (works)
HTTP POST https://localhost:8080/v1/generate (fails 404)
(api key enabled on all)
proto
```protobuf
service MainService {
rpc Generate(GenerateRequest) returns (GenerateResponse) {
option (google.api.http) = {
post: "/v1/generate"
body: "*"
};
}
}
message GenerateRequest {
string id = 1;
string type = 2;
}
```
api_config.yaml
```yaml
type: google.api.Service
config_version: '3'
name: **********
title: Google Cloud Run ESPv2 gRPC Endpoint
apis:
- name: cfg.main.v1.MainService
usage:
rules:
- selector: '*'
allow_unregistered_calls: false
backend:
rules:
- selector: cfg.main.v1.MainService.*
address: grpc://main:8081
deadline: 1800
```
docker-compose.yaml
```yaml
main:
# ...
endpoint:
platform: linux/amd64
image: gcr.io/endpoints-release/endpoints-runtime:2
command: [
'--listener_port=8080',
'--service_json_path=/usr/src/service_config.json',
'--service_account_key=/usr/src/endpoint.key',
# '--disable_tracing',
'--non_gcp',
'--cors_preset=basic',
'--generate_self_signed_cert',
# '--cors_allow_headers=x-user-agent,x-grpc-web,authorization,content-type',
# '--enable_debug',
]
ports:
- 8080:8080
volumes:
- ./apps/endpoint/service_config.json:/usr/src/service_config.json
- ./apps/endpoint/endpoint.key:/usr/src/endpoint.key
```
Contributor guide
Research direction
Reproduce the local sidecar setup using docker-compose.yaml, service_config.json, api_config.yaml, and the provided proto definition. Compare the working gRPC requests with POST /v1/generate and inspect ESPv2's local routing behavior; done means the annotated HTTP path reaches MainService.Generate locally without a 404.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker
- Domain
- api, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100