pulumi / pulumi-gcp

A Google Cloud Platform (GCP) Pulumi resource package, providing multi-language access to GCP
Apache License 2.0
177 stars 50 forks source link

The Pulumi Docs for autoscaling in GCP Cloud Run are wrong #1291

Open nick-catalist opened 9 months ago

nick-catalist commented 9 months ago

What happened?

https://www.pulumi.com/registry/packages/gcp/api-docs/cloudrun/service/

The docs describe how to set autoscaling via knative annotations in a Cloud Run service. They claim that this should be in the top level "metadata" field on the service, of type ServiceMetadataArgs:

Optional metadata for this Revision, including labels and annotations. Name will be generated by the Configuration. To set minimum instances for this revision, use the "autoscaling.knative.dev/minScale" annotation key. To set maximum instances for this revision, use the "autoscaling.knative.dev/maxScale" annotation key. To set Cloud SQL connections for the revision, use the "run.googleapis.com/cloudsql-instances" annotation key. Structure is documented below.

However, this is incorrect, and setting this annotation will not set autoscaling on your Cloud Run service. It's easy to reproduce this, just create a cloud run via Pulumi using this recommendation. It will indeed set an annotation on the service-level metadata, but you can see in the GCP console that the "min instances" is unset. If you set min instances via the GCP console, you'll see that this annotation actually gets set at spec.template.metadata instead.

Example

cloud_run_service = cloudrun.Service(
            "cloud-run",
            name="service",
...
            metadata=cloudrun.ServiceMetadataArgs(
                annotations={
                    "autoscaling.knative.dev/minScale": "1",
                }
            ),

Output of pulumi about

N/A

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

nick-catalist commented 9 months ago

I ended up moving to Cloud Run v2 API which handles this much better. I would encourage anyone looking here to do the same.

That said, the docs should still probably not mislead those still on v1 :)

mikhailshilkov commented 8 months ago

This is defined upstream, the same comment exists for both annotations:

I'm not exactly sure why they do it, but I think we apply all the docs truthfully.