Google Cloud Functions:将Gen1迁移到Gen2函数时出现错误

huangapple go评论52阅读模式
英文:

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

问题

我正在尝试将一个测试函数从Gen1迁移到Gen2。我通过控制台将其删除,并使用以下命令(通过Github操作)进行部署。我在底部收到了以下错误信息,这并没有什么意义,因为我没有指定任何内存大小。

有人经历过这种情况吗?

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.
英文:

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.

答案1

得分: 3

错误消息:

spec.template.spec.containers.resources.limits.memory: 内存的值无效。
对于指定的值,maxScale 不得超过 83。

表示现有的第一代云函数可能将 maxScale 设置为超过 83。在迁移到第二代时,默认内存可能已按照文档 设置为 256 MB,并且最大规模大于 83,这可能导致上述错误。

因此,我已将 --max-instances=30 设置为根据内存平衡最大实例数。
但是,您也可以根据需要通过 --max-instances 修改此值。

--memory 标志也适用相同的原则。

更新后的命令将是:

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 }}

参考:gcloud functions deploy

英文:

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

huangapple
  • 本文由 发表于 2023年5月17日 15:33:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76269567.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定