ERROR: (gcloud.endpoints.services.deploy) INVALID_ARGUMENT: Cannot convert to service config

338 views
Skip to first unread message

Denis Rhoden Jr

unread,
Aug 12, 2020, 4:31:43 AM8/12/20
to Google Cloud Endpoints
This issue arises when I try to deploy my service configuration. I've generated Swagger definitions using protoc-go-automatically, as well as my api_descriptor.pb. I've tracked down the issue to the `apis` object in my api_config.yaml

'location: "api_config.yaml:6"
kind: ERROR
message: "Cannot resolve api \'example.api.v1.MyService\'."

As soon as I introduce a value for apis[0].name it fails validation.

type: google.api.Service
config_version: 3
name: GATEWAY-*-uc.a.run.app
title: My API
apis:
- name: example.api.v1.MyService
usage:
  rules:
  - selector: example.api.v1.MyService.AddPerson
    allow_unregistered_calls: true
backend:
  rules:
  - selector: '*'
    address: grpcs://BACKEND-*-uc.a.run.app

I can successfully use grpcurl `describe` method to retrieve information about the RPC server from the gateway, but no other calls work. I can do the same directly hitting the backend gRPC.

This approach passes validation for spec definitions:

gcloud endpoints services deploy openapi_run.json

This does not:

gcloud endpoints services deploy api_descriptor.pb api_config.yaml

My proto file looks like this:

syntax = "proto3";

package example.api.v1;

import "protoc-gen-openapiv2/options/annotations.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";

option java_package = "com.example.api.v1";
option java_multiple_files = true;
option java_outer_classname = "ApiProto";
option go_package = "github.com/example/api/proto/gen/go/example/api/v1;apipb";

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  info: {
    title: "Gateway";
    version: "0.0.1";
  },
  host: "GATEWAY-*-uc.a.run.app";
  extensions: {
    key: "x-google-backend";
    value {
      struct_value {
        fields {
          key: "address";
          value {
            string_value: "https://BACKEND-*-uc.a.run.app";
          }
        }
        fields {
          key: "protocol";
          value {
            string_value: "h2";
          }
        }
      }
    }
  }
};

service MyService {
  // endpoint for creating a person
  rpc AddPerson(AddPersonRequest) returns (AddPersonResponse) {
    option (google.api.http) = {
      post: "/v1/person",
      body: "*"
    };
  }


message AddPersonRequest {
  string email = 1;
  string name = 2;
}


message AddPersonResponse {
  string id = 1;
  string name = 2;
  string display_name = 3;
  google.protobuf.Timestamp create_time = 4;
}
}

Teju Nareddy

unread,
Aug 12, 2020, 11:28:08 AM8/12/20
to Denis Rhoden Jr, Google Cloud Endpoints
The proto file and the yaml file look correct to me, the package names match. Just to double check, can you make sure api_descriptor.pb file is up to date? Or can you use protoc directly to re-compile the api_descriptor.pb, I am not familiar with protoc-go-automatically.

I have one concern with your deployment model though:

Cloud Endpoints supports either OpenAPI or gRPC for an Endpoints Service. You can choose to use either one, but you should not use both for a single service. 

If you have a proto file, then you want a gRPC Cloud Endpoints service. So you should only run the following command: `gcloud endpoints services deploy api_descriptor.pb api_config.yaml`. You do NOT need to run `gcloud endpoints services deploy openapi_run.json`, this is OpenAPI only. 

If you deployed an OpenAPI file to this endpoints service first, then it's possible there is some caching going on in Google Service Management that prevents you from deploying gRPC. I would try creating a new service for your gRPC deploy. This means getting a new Cloud Run instance and changing the `name` field in the yaml file, so it will be a different Cloud Endpoints service.

You can follow this tutorial for deploying gRPC on Cloud Run, in case you forgot the initial setup: https://cloud.google.com/endpoints/docs/grpc/get-started-cloud-run

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/a1332cf8-dbd5-41b8-9a91-2d8de8c01d10n%40googlegroups.com.


--

Teju Nareddy

nare...@google.com

Software Engineer

Reply all
Reply to author
Forward
0 new messages