3

I use Google's Cloud Run (fully managed) to run an app that I'm building. When I deploy a new revision, I'd like to be able to verify that various health checks are ok before I start sending it traffic, but I haven't been able to find a URL for individual (traffic-less) revisions. Is there anything similar to what I'm looking for?

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
Pete K
  • 118
  • 6
  • What aspect are you thinking of testing? If it is logic, then my mind is thinking that you would deploy it to its own Cloud Run deployment separate from production and running function tests against it. – Kolban Jun 07 '20 at 04:06
  • I already do that with a staging environment, so what I'm really looking to test is that inside the environment of production (all env variables set to relevant prod values), the new revision behaves alright. I guess a kludgy fix would be to deploy it as a separate service, but what with Cloud Run's awesome traffic control feature, I'd think there'd be some sort of way to check health of a revision before sending traffic to it. – Pete K Jun 07 '20 at 11:11
  • Howdy Pete ... I hear you ... what I think you are asking for is a means to deploy a new revision and have 0% traffic sent to it ... but somehow still provide an invocation mechanism that can be used by operations to somehow "sanity check it". I haven't seen anything like that available. I'm pretty much thinking that we trust that the environment is working as advertized. If we didn't 100% trust the deployment, then we would have bigger issues. Maybe use traffic splitting and set the new deployment to be VERY low and monitor it carefully? – Kolban Jun 07 '20 at 13:30

2 Answers2

5

This is possible using "Revision tags", a feature currently in alpha:

By creating a tag latest that always point to the latets revision, you will be able to access it under the URL https://latest---<SERVICE>-<HASH>.a.run.app.

To do so, use this command:

gcloud alpha run services update-traffic --update-tags latest=LATEST

When deploying, make sure to not migrate traffic to the new revision with:

gcloud run deploy --image ... --no-traffic

After testing the newly created revision, send 10% of the traffic traffic to it with

gcloud alpha run services update-traffic --to-tags latest=10
Steren
  • 7,311
  • 3
  • 31
  • 51
0

Yes, you can test a new revision before sending traffic to it.

Now, there is the current revision "editor-v1-0-0":

enter image description here

First, to test a new revision by opening the url, you need to add a tag to a new revision. So, to add a tag to a new revision, add the flag as shown below to the command which creates a new revision (It's also possible to add a tag to a new revision with both command and GUI even after creating a new revision):

--tag <tag>

Now, I'll add the tag "green" to a revision:

--tag green

Second, not to send any traffic to a new revision after creating it, you also need to add the flag as shown below to the command (You cannot use this flag with the command if no revisions exist when creating a new revision):

--no-traffic

Then, including 2 flags above, I run the full command referring to Shipping the public editor service in Securing Cloud Run services tutorial as shown below to create a new revision with "editor:2.0.0" image:

gcloud run deploy editor --image gcr.io/myproject-318173/editor:2.0.0 \
    --service-account editor-identity \
    --set-env-vars EDITOR_UPSTREAM_RENDER_URL=https://renderer-4bdlubpdxq-an.a.run.app \
    --allow-unauthenticated \
    --revision-suffix v2-0-0 \
    --tag green \
    --no-traffic

Now, the new revision "editor-v2-0-0" is created with the tag "green" and "0% Traffic" as shown below:

enter image description here

Then, when clicking on "green" tag of the new revision "editor-v2-0-0":

enter image description here

You can open and test the new revision as shown below before sending traffic to the new revision:

enter image description here

And the URL above is:

https://green---editor-4bdlubpdxq-an.a.run.app

And by clicking on "️":

enter image description here

For example, you can change "green":

enter image description here

To "blue" with GUI:

enter image description here

And you can add more tag "yellow":

enter image description here

And you can also remove the tags:

enter image description here

But if you remove the tag, you cannot open and test the new revision:

enter image description here

In addition, you can also change, add and remove tags by clicking on "⋮" then "Manage revision URLs (tags)":

enter image description here

enter image description here

Lastly, I posted the answer explaining more about tags so see it if you want to know more about tags.

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129