Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bucket Object is not properly updated when source changes #948

Open
zbuchheit opened this issue Dec 20, 2023 · 1 comment
Open

Bucket Object is not properly updated when source changes #948

zbuchheit opened this issue Dec 20, 2023 · 1 comment
Labels
customer/feedback Feedback from customers customer/lighthouse kind/bug Some behavior is incorrect or out of spec

Comments

@zbuchheit
Copy link

zbuchheit commented Dec 20, 2023

What happened?

Background

When attempting to use a Bucket Object, I observed that changing a bucket object's content was not actually resulting in changes on the bucket object. Changes to the object triggered an update on the Bucket Object, but when you download the content you will see no changes have actually been reflected.

Example

function.js Function

const functions = require('@google-cloud/functions-framework');

functions.http('helloGET', (req, res) => {
  res.send('Hello World!'); //Change me to observe behavior
});

index.ts Snippet

const bucket = new googleNative.storage.v1.Bucket("zbuchheit-bucket", {
    storageClass: 'STANDARD',
    project: project,
    iamConfiguration: {
        publicAccessPrevention: 'enforced',
    },
});

const functionArchive = new asset.AssetArchive({
    ".": new asset.FileArchive("./function"),
});

const object = new googleNative.storage.v1.BucketObject('zbuchheit-native-bucket-object', {
    bucket: bucket.name,
    source: functionArchive,
}, {
    // replaceOnChanges: ["source"], //Uncomment this line as a workaround
});

Example Repo

https://github.com/zbuchheit/pulumi-examples/tree/main/gcp-native-ts-function-v2

Output of pulumi about

CLI          
Version      3.92.0
Go Version   go1.21.3
Go Compiler  gc

Plugins
NAME           VERSION
gcp            7.3.1
google-native  0.32.0
nodejs         unknown

Host     
OS       darwin
Version  14.0
Arch     arm64

This project is written in nodejs: executable='/Users/zbuchheit/.nvm/versions/node/v18.17.1/bin/node' version='v18.17.1'

Current Stack: zbuchheit-pulumi-corp/gcp-native-ts-zbuchheit/dev

TYPE                                      URN
pulumi:pulumi:Stack                       urn:pulumi:dev::gcp-native-ts-zbuchheit::pulumi:pulumi:Stack::gcp-native-ts-zbuchheit-dev
pulumi:providers:google-native            urn:pulumi:dev::gcp-native-ts-zbuchheit::pulumi:providers:google-native::default_0_32_0
google-native:storage/v1:Bucket           urn:pulumi:dev::gcp-native-ts-zbuchheit::google-native:storage/v1:Bucket::zbuchheit-bucket
pulumi:providers:gcp                      urn:pulumi:dev::gcp-native-ts-zbuchheit::pulumi:providers:gcp::default_7_3_1
google-native:storage/v1:BucketObject     urn:pulumi:dev::gcp-native-ts-zbuchheit::google-native:storage/v1:BucketObject::zbuchheit-native-bucket-object
gcp:storage/bucketObject:BucketObject     urn:pulumi:dev::gcp-native-ts-zbuchheit::gcp:storage/bucketObject:BucketObject::zbuchheit-classic-bucket-object
google-native:cloudfunctions/v2:Function  urn:pulumi:dev::gcp-native-ts-zbuchheit::google-native:cloudfunctions/v2:Function::zbuchheit-function-2
google-native:cloudfunctions/v2:Function  urn:pulumi:dev::gcp-native-ts-zbuchheit::google-native:cloudfunctions/v2:Function::zbuchheit-function-1


Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/zbuchheit-pulumi-corp
User           zbuchheit-pulumi-corp
Organizations  zbuchheit-pulumi-corp
Token type     personal

Dependencies:
NAME                   VERSION
@pulumi/gcp            7.3.1
@pulumi/google-native  0.32.0
@pulumi/pulumi         3.98.0
@types/node            18.19.3

Pulumi locates its logs in /var/folders/lh/l71cdh810xb33t0jc7qmt5_80000gn/T/ by default

Additional Context

It is worth noting in the pulumi-gcp provider, a source change to a bucket object will result in a replace of the resource, and in the pulumi-google-native provider it will only result in an update of the resource. Below is an example preview between the two resources.

    ~ google-native:storage/v1:BucketObject: (update)
      # ID and URN ommitted for brevity
      + source: archive(assets:7e85920) {
      +     ".": archive(file:7e85920) { ./function }
        }
    ++gcp:storage/bucketObject:BucketObject: (create-replacement)
      # ID and URN ommitted for brevity
      ~ detectMd5hash: "BN5OQClmhhUlmcF2IqUnOg==" => "different hash"
      ~ source       : archive(assets:3c109f5->7e85920) {
          ~ ".": archive(file:3c109f5->7e85920) { ./function }
        }
    +-gcp:storage/bucketObject:BucketObject: (replace)
      # ID and URN ommitted for brevity
      ~ detectMd5hash: "BN5OQClmhhUlmcF2IqUnOg==" => "different hash"
      ~ source       : archive(assets:3c109f5->7e85920) {
          ~ ".": archive(file:3c109f5->7e85920) { ./function }
        }

Related Issue

I encountered this issue when attempting to replicate #370 which this issue is the root cause for. This could be viewed as a duplicate as #370 but I believe this issue to be more reflective of the upstream issue.

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

@zbuchheit zbuchheit added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Dec 20, 2023
@zbuchheit
Copy link
Author

Documenting a workaround to this issue for other users. I was able to resolve this issue by using replaceOnChanges set to the source to trigger a replace when the source changes.

const object = new googleNative.storage.v1.BucketObject('zbuchheit-native-bucket-object', {
    bucket: bucket.name,
    source: functionArchive,
}, {
    replaceOnChanges: ["source"], //Workaround
});

@mjeffryes mjeffryes removed the needs-triage Needs attention from the triage team label Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer/feedback Feedback from customers customer/lighthouse kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

3 participants