pulumi / pulumi-gcp

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

pubsub.NewSubscription failed to update created Subscription #1162

Open sfc-gh-llin opened 1 year ago

sfc-gh-llin commented 1 year ago

What happened?

pubsub.NewSubscription of github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/pubsub failed to update the subscription with * Error updating Subscription "projects/<projectName>/subscriptions/<subscriptionName>": googleapi: Error 400: The update_mask in the UpdateSubscriptionRequest must be set, and must contain a non-empty paths list. when we add a new arg to it.

Expected Behavior

subscription should be updated without error.

Steps to reproduce

  1. create a pubsub Subscription

    subscription, err := pubsub.NewSubscription(Ctx, <subscriptionName>, &pubsub.SubscriptionArgs{
    Topic:              <TopicName>,
    Project:            <ProjectId>,
    })
    if err != nil {
    return err
    }

    subscription created

  2. add an arg to update, and run pulumi up

    subscription, err := pubsub.NewSubscription(Ctx, <subscriptionName>, &pubsub.SubscriptionArgs{
    Topic:              <TopicName>,
    Project:            <ProjectId>,
    AckDeadlineSeconds: pulumi.Int(600),
    })
    if err != nil {
    return err
    }

    subscription failed with

    * Error updating Subscription "projects/<projectID>/subscriptions/<subName>": googleapi: Error 400: The update_mask in the UpdateSubscriptionRequest must be set, and must contain a non-empty paths list.

Output of pulumi about

CLI          
Version      3.74.0
Go Version   go1.20.5
Go Compiler  gc

Plugins
NAME  VERSION
gcp   6.50.0
go    unknown

Host     
OS       darwin
Version  13.5
Arch     arm64

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

danielrbradley commented 1 year ago

Hi @sfc-gh-llin thanks for getting in touch.

From an initial read, this looks like it could be similar to this old upstream issue: https://github.com/hashicorp/terraform-provider-google/issues/7562. My reading of this issue is that the field was not mutable and therefore any modification to it required deleting and recreating the resource.

Reading the documentation for the pubsub subscription patch method it appears that the subscription.ackDeadlineSeconds property is able to be updated. This document also includes the updateMask which it describes as:

Required. Indicates which fields in the provided subscription to update. Must be specified and non-empty. This is a comma-separated list of fully qualified names of fields. Example: "user.displayName,photo".

It would appear that the underlying provider is failing to set this field correctly.

Here is the code where the update mask should be being set:

https://github.com/modular-magician/terraform-provider-google-beta/blob/20d1dec96c4f895048bdfa86f7bba89f497c7b48/google-beta/services/pubsub/resource_pubsub_subscription.go#L861C1-L863C3

The next step here would be to use verbose logging to see what we're passing to the provider for this field or to identify if the same error occurs using the terraform provider directly.