1
votes

I deployed two Cloud Run services (staging and production) using GCP Cloud Build with this command:

entrypoint: gcloud
  args: ['run', 'deploy', 'app', '--project', '$PROJECT_ID', '--image', 'image:$COMMIT_SHA', '--region', 'us-central1', '--allow-unauthenticated', '--memory' , '256Mi', '--update-env-vars', 'ENV=production']

I noticed that the same command has different behavior on staging and production. On one of my services, the traffic is not routed automatically to the newest revision.

Already have image (with digest): 
Deploying container to Cloud Run service 
Deploying...
Setting IAM Policy..............done
Creating Revision..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................done
Done.

Service [] revision [] has been deployed and is serving 0 percent of traffic.

I am missing this step : 

Routing traffic......done

I checked the cloud run service.yaml and the traffic argument is set :

 traffic:
  - latestRevision: true
    percent: 100

If I run the same command on GCP console, everything works as expected.

Question: Why gcloud run deploy does not route the traffic when I am running from Cloud Build pipeline ? ( I do not have --no traffic flag set)

1
Did you play on the UI with the traffic splitting?guillaume blaquiere
No, I did not play with traffic splitting?marian.vladoi
Are you gcloud sdk up to date?guillaume blaquiere
I am just trying to deploy from cloud buil but the thraffic is not routed. The same command works fine from cloud shell. This is the command gcloud run deploy prod --project xxxx --image image:xxx --region us-central1 --allow-unauthenticated --memory 256Mi --update-env-vars ENV=productionmarian.vladoi

1 Answers

0
votes

It seems to be related to this issue: https://issuetracker.google.com/issues/172165141

There are two modes available to you: route traffic to latest revision or manually distribute it. If you switched to manual routing the service stays like this until you decide to revert it back with gcloud run services update-traffic testservice --platform="managed" --to-latest.. This is made to keep it simple and fight ambiguity and unexpected traffic switch.