5

I have a service created on Google Cloud run that I am able to deploy manually through the Google Cloud Console UI using an image on Container registry. But deployment from CLI is failing. Here is the command I am using and the error I get. I am not able to understand what I am missing:

$ gcloud beta run deploy service-name --platform managed --region region-name --image image-url
Deploying container to Cloud Run service [service-name] in project [project-name] region [region-name]
X Deploying...
  . Creating Revision...
  . Routing traffic...
Deployment failed
ERROR: (gcloud.beta.run.deploy) INVALID_ARGUMENT: The request has errors
- '@type': type.googleapis.com/google.rpc.BadRequest
  fieldViolations:
  - description: spec.revisionTemplate.spec.container.ports should be empty
    field: spec.revisionTemplate.spec.container.ports

Update 1: I have updated the SDK using gcloud components update, but I still have the same issue

Here's my SDK Version

$gcloud version
Google Cloud SDK 270.0.0
beta 2019.05.17
bq 2.0.49
core 2019.11.04
gsutil 4.46

I am using a multistage docker build. Here's my Dockerfile:

FROM custom-dev-image

COPY . /project_dir
WORKDIR /project_dir
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
  /usr/local/bin/go build -a \
  -ldflags '-w -extldflags "-static"' \
  -o /root/go/bin/executable ./cmds/project/main.go

FROM alpine:3.10
ENV GIN_MODE=release APP_NAME=project_name
COPY --from=0 /root/go/bin/executable /usr/local/bin/
CMD executable

pcx
  • 984
  • 11
  • 21
  • 1
    Can you share the version of the gcloud SDK `gcloud version`? Can you share your dockerfile? – guillaume blaquiere Nov 05 '19 at 14:31
  • Not sure if this is your case, but if you are trying to expose your configuration. I would suggest you follow this [example](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#exposing-pods-to-the-cluster). Please notice that `ports` is empty and `containerPort: 80` is what gets the value. Otherwise, please share more information about your configuration. – sllopis Nov 05 '19 at 14:55
  • 1
    You need to update the CLI `gcloud components update`. – John Hanley Nov 05 '19 at 15:05
  • @guillaumeblaquiere I've updated the questions with my SDK version and dockerfile – pcx Nov 06 '19 at 06:43
  • @JohnHanley updating the components did not help :( – pcx Nov 06 '19 at 06:43
  • @sllopis I am not using Kubernetes, not sure how your suggestion applies for Google Cloud Run. There is not custom configuration I am using, just a dockerfile – pcx Nov 06 '19 at 06:45
  • The error message description is `spec.revisionTemplate.spec.container.ports should be empty`, I found out that the `container` part is [deprecated](https://cloud.google.com/run/docs/reference/rpc/google.cloud.serverless.v1alpha1#google.cloud.serverless.v1alpha1.RevisionSpec.FIELDS.google.cloud.serverless.v1alpha1.Container.google.cloud.serverless.v1alpha1.RevisionSpec.container). Also, check your `ports` array because you may have put some values in it and must be empty, as stated in the error message. – sllopis Nov 06 '19 at 09:28
  • More info about `ports` can be found [here](https://cloud.google.com/run/docs/reference/rpc/google.cloud.serverless.v1alpha1#google.cloud.serverless.v1alpha1.Container.FIELDS.repeated.google.cloud.serverless.v1alpha1.ContainerPort.google.cloud.serverless.v1alpha1.Container.ports) – sllopis Nov 06 '19 at 09:28
  • 1
    @pcx I workaround by recreating service in Cloud Run then run deploy again. It's seem to be some issue with Cloud Run service. – Juk Nov 06 '19 at 16:44
  • 1
    facing the same problem here – Hady Rashwan Nov 07 '19 at 09:47
  • in my case the build works with the cli however I cant deploy I use the ui for now to deploy the new version – Hady Rashwan Nov 07 '19 at 09:55
  • 1
    @Juk I have opened an issue in the official tracker here https://issuetracker.google.com/issues/144069696. Please add any information to this issue that can be helpful. Thanks! – pcx Nov 07 '19 at 09:57
  • @HadyRashwan Same here, I am deploying manually using the UI now. This is a really big breakage for a google service, despite it being in beta! yikes – pcx Nov 07 '19 at 09:57

2 Answers2

2

I had this same problem and I assume it was because I had older Cloud Run deployment that was created before I had ran gcloud components update since some update.

I was able to fix it by deleting the whole Cloud Run service (through the GUI) and deploying it from scratch again (via terminal). I noticed that the ports: definition disappeared from the YAML once I did this.

After this I could do deployments normally.

tomtom
  • 21
  • 1
  • Now i facing this issue instead Creating Revision...................interrupted Deployment failed ERROR: (gcloud.beta.run.deploy) Resource readiness deadline exceeded. I'm not sure that 'gcloud beta run deploy' timeout is the cause ?? But when i rerun again it works, sound weird. – Juk Nov 07 '19 at 14:45
  • Thank you. The same fix worked for me. After deleting and recreating the service, I can now push new revisions of the Cloud Run service from gcloud CLI. – Jonathan Fuerth Nov 07 '19 at 22:11
2

This was a bug in Cloud Run. It has been fixed and deploying with CLI is working for me now. Here's the link to the issue I had raised with Google Cloud which has a response from them https://issuetracker.google.com/issues/144069696.

pcx
  • 984
  • 11
  • 21