pulumi / pulumi-gcp

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

GCP Cloud Run v2 service always being updated when `launch_stage` is BETA while using python sdk #2336

Open nabheet opened 2 months ago

nabheet commented 2 months ago

What happened?

We have a GCP Cloud Run V2 service defined in Pulumi. When I use the launch_stage="BETA" , Pulumi always updates the service instance. Even when nothing has changed.

However, it does not update the service instance if launch_state="BETA" is not specified.

We were hoping that the specification of launch_stage does not automatically update the service on every deployment.

Example

We have a Cloud Run v2 service like this:

cloud_run_service = cloudrunv2.Service(
            "{}-cloud-run-service".format(service_name),
            location=region,
            name=service_name,
            project=project_id,
            client="gcloud",
            custom_audiences=custom_audiences,
            launch_stage="BETA",
            scaling=cloudrunv2.ServiceScalingArgs(
                min_instance_count=min_scale,
            ),
            template=cloudrunv2.ServiceTemplateArgs(
                scaling=cloudrunv2.ServiceTemplateScalingArgs(
                    max_instance_count=max_scale,
                    min_instance_count=0,
                ),
                containers=containers,
                volumes=volumes,
                service_account=service_account,
                max_instance_request_concurrency=container_concurrency,
                timeout=f"{timeout_seconds}s",
                vpc_access=cloudrunv2.ServiceTemplateVpcAccessArgs(
                    network_interfaces=[
                        cloudrunv2.ServiceTemplateVpcAccessNetworkInterfaceArgs(
                            network=default_network.name,
                            subnetwork=cloud_run_subnet.name,
                        )
                    ],
                    egress="ALL_TRAFFIC",
                ),
                execution_environment="EXECUTION_ENVIRONMENT_GEN2",
            ),
            ingress="INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER",
            opts=ResourceOptions(
                aliases=[Alias(name=service_name)],
                delete_before_replace=True,
                depends_on=dependencies,
                ignore_changes=[
                    "template.containers[0].image",
                    "template.containers[0].commands",
                    "template.containers[0].args",
                    "clientVersion",
                ],
            ),
        )

Pulumi updates the service on every execution reporting:

~ gcp:cloudrunv2/service:Service: (update)
        [id=projects/PROJECT_ID/locations/us-central1/services/SERVICE_NAME]
        [urn=urn:pulumi:BLA_BLA::PROJECT_ID::gcp:cloudrunv2/service:Service::SERVICE_NAME_BLA_BLA]
        [provider=urn:pulumi:BLA_BLA::PROJECT_ID::pulumi:providers:gcp::default_7_32_0::4e01aa79-5e47-4fc4-86e9-4a34aeb920b9]
      ~ launchStage: "GA" => "BETA"
      + scaling    : {
          + minInstanceCount: 0
        }
      + scaling    : {
          + minInstanceCount: 0
        }

I believe pulumi should not update the service if nothing has changed.

Output of pulumi about

$ pulumi about
CLI          
Version      3.129.0
Go Version   go1.22.6
Go Compiler  gc

Host     
OS       debian
Version  12.6
Arch     aarch64

Backend        
Name           pulumi.com
URL            https://app.pulumi.com
User           Unknown
Organizations  
Token type     personal

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).

justinvp commented 2 months ago

Hi @nabheet, thanks for opening the issue. This looks specific to the GCP provider, so I'm going to transfer the issue there. From a cursory look, this may be an issue in the upstream provider: https://github.com/hashicorp/terraform-provider-google/issues/13748

iwahbe commented 2 months ago

Hi @nabheet. This (pulumi-gcp) is indeed the correct repo to house this issue. I agree with @justinvp, this is an upstream issue. As soon as they take a fix for https://github.com/hashicorp/terraform-provider-google/issues/13748, we will incorporate it into pulumi-gcp.