Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP endpoint with google.api.http annotation doesn't transcode locally #906

Open
danielmahon opened this issue May 23, 2024 · 0 comments
Open

Comments

@danielmahon
Copy link

danielmahon commented May 23, 2024

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

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

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

  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
@danielmahon danielmahon changed the title HTTP endpoints with google.api annotations don't transcode locally HTTP endpoint with google.api.http annotation doesn't transcode locally May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant