RopeySim
RopeySim

Reputation: 511

Google Cloud Functions: Error when migrating a Gen1 to Gen2 function

I am trying to move a test function from Gen1 to Gen2. I deleted it through the console, and used the following command (through Github actions) to deploy. I get the error at the bottom, which doesn't make sense since I'm not specifying any memory size.

Has anyone experienced this?

        gcloud -q functions deploy hello_world \
          --gen2 \
          --runtime python310 \
          --trigger-http \
          --allow-unauthenticated \
          --region us-central1 \
          --source functions/src \
          --service-account=${{ secrets.GCP_SA_EMAIL }}
ERROR: (gcloud.functions.deploy) ResponseError: status=[400], code=[OK],
message=[Could not create Cloud Run service hello-world.

spec.template.spec.containers.resources.limits.memory: Invalid value
specified for memory. For the specified value, maxScale may not exceed 83.

Upvotes: 0

Views: 1219

Answers (1)

Rohit Kharche
Rohit Kharche

Reputation: 2919

The error message :

spec.template.spec.containers.resources.limits.memory: Invalid value
specified for memory. For the specified value, maxScale may not exceed 83.

means the existing gen 1 cloud function may have a maxScale set to more than 83. While migrating to gen2 default memory might have been taken by default as 256 MB as per documentation and max scale is greater than 83 which might be giving above error.

Hence I have set the --max-instances=30 to balance max-instances according to memory. But you can also modify this value as per requirement by --max-instances .

The same applies to the --memory flag.

The updated command will be :

gcloud -q functions deploy hello_world \
          --gen2 \
          --runtime python310 \
          --memory=512MiB \
          --max-instances=30 \
          --trigger-http \
          --allow-unauthenticated \
          --region us-central1 \
          --source functions/src \
          --service-account=${{ secrets.GCP_SA_EMAIL }}

Reference : gcloud functions deploy

Upvotes: 4

Related Questions