Versioning with endpoint V2 on GAE

2019-03-17 01:41发布

I have the live version of my app deployed with its endpoints (no problem with that). I also want to easily be able to test other versions (e.g. staging).

With endpointV1: no problem.

With endpointV2: Everything works fine if I deploy to the live version (at https://[PROJECT-ID].appspot.com but does not work for other versions.

After deploying to staging at https://staging-dot-[PROJECT-ID].appspot.com the deployment is successful, but when the frontend calls the backend, the request is received by the backend (I can see it in the GAE logs and trace list), but it does not make it to or though endpointV2 and responds 404 NOT FOUND:

"errors": [ { "domain": "global", "reason": "notFound", "message": "\u003chtml\u003e\u003chead\u003e\n\u003cmeta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\"\u003e\n\u003ctitle\u003e404 NOT_FOUND\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody text=#000000 bgcolor=#ffffff\u003e\n\u003ch1\u003eError: NOT_FOUND\u003c/h1\u003e\n\u003c/body\u003e\u003c/html\u003e\n" }

I now use the following maven plugins:

<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>1.3.1</version>
    <configuration>
        <!-- deploy configuration -->
    </configuration>
</plugin>
<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>endpoints-framework-maven-plugin</artifactId>
    <version>1.0.0</version>
</plugin>

I have adjusted the versions in appengine.xml and in the Google Cloud plugin. How can I configure endpoint to work with a specific module version instead of only the main version?

2条回答
Bombasti
2楼-- · 2019-03-17 01:59

While not really an answer, I saw this:

When deploying a legacy type endpoint (V1), everything works fine, https://3-dot-xx.appspot.com/_ah/api/discovery/v1/apis will show the APIs deployed to version 3

When deploying a new type endpoint (v2), eg 2-dot-, it depends on the last V1 endpoint deployed on the version.

  • if it is a new version with no V1 endpoint deployed before, it works and the new endpoint is shown on 2-dot-
  • if there was a V1 endpoint deployed here before, it will show the old V1 apis and naturally generate a 404 when accessing, as the actually running GAE version is different
  • if the version was never deployed at all (eg asdf-dot-), or using the default (without the -dot- etc), it will show the default version and access it correctly.
  • if there never was a V1 service deployed, but a V2 service, it works fine when deploying a new V2 service

So, it seems like there is a bug that will prevent you from using stable names for testing / staging environments if you already had a V1 service running on them. It would be very helpful if someone from Google could confirm this bug and suggest an appropriate workaround before I have to do a lot of costly changes to change URLs.

查看更多
在下西门庆
3楼-- · 2019-03-17 02:09

The short answer for me was: do not reuse version names that were previously used with endpointV1.

E.g. I had a testing-dot-MYPROJECT.appspot.com.

I now use a different version: test-dot-MYPROJECT.appspot.com.

For the long answer, have a look at cputoaster's answer.

查看更多
登录 后发表回答