💨

always-allocated CPUのCloud RunでInvalid value specified for memoryのエラー

2022/10/27に公開

TLDR

  • always-allocated CPUを使っている場合、first generationのCloud Runでも512MiBのメモリが最低値
  • エラー分で表示されるドキュメントには、このことが書かれていない

エラー内容

Cloud Runのメモリ割り当てを減らそうとした時に以下のエラーが出ました

 Step #0: Deployment failed
 Step #0: ERROR: (gcloud.beta.run.services.replace) spec.template.spec.containers[0].resources.limits.memory: Invalid value specified for memory with cpu unthrottled. For 1.0 CPU, memory must be between 512Mi and 4Gi inclusive.
 Step #0: For more troubleshooting guidance, see https://cloud.google.com/run/docs/configuring/memory-limits
 Finished Step #0

エラーの原因がドキュメントに載っていない

エラー分の中にドキュメントのURLが載っていたので、てっきりドキュメントに書いてあると思ったのですが、書いておらずに混乱しました。

https://cloud.google.com/run/docs/configuring/memory-limits

こちらのドキュメントにはCloud Runの1st/2nd generationの違いや最低メモリの条件について書いていたのですが、エラーの原因がこのドキュメントを読んでも分かりませんでした。

always-allocated CPUが原因だった

エラーの原因は、エラー文で示されていたドキュメントではなくこちらのドキュメントに記載してありました。

https://cloud.google.com/run/docs/configuring/cpu-allocation#setting

If you are choosing the always-allocated CPU option, you must specify at least 512MiB of memory.

always-allocated CPUを使っている場合1st generationのCloud Runでも最低メモリが512MiBである必要がありました。

Discussion