Bug related to basePath on x-google-allow in ESP

1,151 views
Skip to first unread message

AL

unread,
Jul 17, 2017, 4:43:37 PM7/17/17
to Google Cloud Endpoints
I am using ESP to verify API keys for services implemented in a container. Before adding ESP, the service runs in its own container with health check available at url /healthz. The deployment is exposed in a service of type NodePort, which is in turn exposed via an ingress.

After adding the ESP to the pod, I noticed that the health check is failing with the following from the logs:
14:57:49.666us-central1-a404Endpoints management skipped for an unrecognized HTTP call: GET /healthz
{
insertId: "4b2e2341-8af5-4124-9fcd-d77c11a448a0@a1" 
jsonPayload: {
error_cause: "service_control" 
http_method: "GET" 
http_response_code: 404 
location: "us-central1-a" 
log_message: "Endpoints management skipped for an unrecognized HTTP call: GET /healthz" 
producer_project_id: "cds-dev-155819" 
request_latency_in_ms: 0 
request_size_in_bytes: 94 
response_size_in_bytes: 362 
timestamp: 1500321469.666007 
url: "/healthz" 
}
logName: "projects/cds-dev-155819/logs/ees-api.endpoints.cds-dev-155819.cloud.goog%2Fendpoints_log" 
receiveTimestamp: "2017-07-17T19:57:56.909827222Z" 
When this is happening I had the following in swagger.yaml.
# basePath prefixes all resource paths
basePath: /v1
# Default to route all calls such as /docs and /healthz
x-google-allow: all

I tried adding "/healthz" to swagger.yaml and that solved the problem, which means that setting "x-google-allow" to "all" isn't doing what it was supposed to do. After changing the basePath to "/", I am getting the normal health check responses from the log file.
15:13:14.971us-central1-a2001 msMethod: 0.ees_api_endpoints_cds_dev_155819_cloud_goog.Google_Autogenerated_Unrecognized_Get_Method_Call
{
insertId: "28ae159c-e2e8-4719-99c2-78c8f7d71596@a3" 
jsonPayload: {
api_method: "0.ees_api_endpoints_cds_dev_155819_cloud_goog.Google_Autogenerated_Unrecognized_Get_Method_Call" 
api_name: "0.ees_api_endpoints_cds_dev_155819_cloud_goog" 
api_version: "0.0.1" 
http_method: "GET" 
http_response_code: 200 
location: "us-central1-a" 
log_message: "Method: 0.ees_api_endpoints_cds_dev_155819_cloud_goog.Google_Autogenerated_Unrecognized_Get_Method_Call" 
producer_project_id: "cds-dev-155819" 
request_latency_in_ms: 1 
request_size_in_bytes: 94 
response_size_in_bytes: 220 
timestamp: 1500322394.971024 
url: "/healthz" 
}
logName: "projects/cds-dev-155819/logs/ees-api.endpoints.cds-dev-155819.cloud.goog%2Fendpoints_log" 
receiveTimestamp: "2017-07-17T20:13:21.272287004Z" 

Now my swagger.yaml looks like the following:
# basePath prefixes all resource paths
basePath: /
# Default to route all calls such as /docs and /healthz
x-google-allow: all

Apparently having "/v1" in the basePath changes how ESP's interpretation of "x-google-allow".

It's really annoying not being able to define a basePath in swagger. Could you please investigate and see if there is indeed an implementation issue between "basePath" and "x-google-allow"?

Thanks.

AL

qiwz...@google.com

unread,
Jul 18, 2017, 5:41:12 PM7/18/17
to Google Cloud Endpoints
There is a bug in how ESP handles "basePath" for "x-google-allow" = all.  If your basePath is /v1,   allow-all only allow /v1/** to go through.  It should have allowed /** to go through.

Well,  we are redesigning the "x-google-allow" feature. It will be deprecated.   The new feature is called supporting "unspecified-paths", which is more flexible. 

At the mean time, you may have to change your basePath to / to work around this bug before the new feature is release.   we hope to get it out in Q4.

abhi...@busuncle.sg

unread,
Jun 19, 2019, 7:07:22 AM6/19/19
to Google Cloud Endpoints
Any updates to this?

I have a large API and have to manually add "/api/" to every single resource currently, because basePath and x-google-allow don't work together. It's quite painful.

Qiwen Zhang

unread,
Jun 28, 2019, 7:08:03 PM6/28/19
to Google Cloud Endpoints
According to this doc.  This behaviors is by design, some users are counting on such behaviors. 

abhi...@busuncle.sg

unread,
Jun 30, 2019, 8:58:01 AM6/30/19
to Google Cloud Endpoints
The doc states that as long as basePath is configured with a prefix, that is "x.com/api/", "x-google-allow: all" should any unconfigured method such as "x.com/api/unconfigured_users" to go through.

In reality, it doesn't allow it.

Qiwen Zhang

unread,
Jul 1, 2019, 12:11:02 PM7/1/19
to Google Cloud Endpoints
In that case, it is a bug, we need to debug it.   Please open an issue here with followings

1) your service config
2) the request you tried that did not go through.  

If you can get ESP debug log, it will be great.  you can turn it on by adding a ESP flag --enable_debug,  the log will be inside the ESP container, in its /var/log/nginx/error.log

Thanks

-Wayne
Reply all
Reply to author
Forward
0 new messages