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

Refresh pollutes state for programs that use Assets and Archives #1595

Closed
t0yv0 opened this issue Dec 26, 2023 · 2 comments · Fixed by #1671
Closed

Refresh pollutes state for programs that use Assets and Archives #1595

t0yv0 opened this issue Dec 26, 2023 · 2 comments · Fixed by #1671
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed size/S Estimated effort to complete (1-2 days).
Milestone

Comments

@t0yv0
Copy link
Member

t0yv0 commented Dec 26, 2023

What happened?

When using assets and archives, as common for lambas in AWS for example, refresh wipes out the asset/archive information from the state and replaces it with machine-local references. This is inherently dangerous if multiple boxes are used to perform pulumi operations against a shared statefile.

Example

The motivating example is a highly upvoted issue in pulumi-aws:

pulumi/pulumi-aws#3548

pulumi/pulumi-aws#3185 even more minimal repro is here.

Output of pulumi about

See above.

Additional context

N/A

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

@t0yv0
Copy link
Member Author

t0yv0 commented Dec 27, 2023

Seeing lots of incidences in azure tests as well. Any time azure:storage/blob:Blob is used, in particular when used with overlays that automatically provision functions like this one:

export const subscription = topic.onEvent("test", async (context, arg) => {

@iwahbe
Copy link
Member

iwahbe commented Dec 28, 2023

I've added this bug to the planning sheet for next iteration.

@t0yv0 t0yv0 added the size/S Estimated effort to complete (1-2 days). label Jan 22, 2024
@t0yv0 t0yv0 self-assigned this Jan 31, 2024
@t0yv0 t0yv0 added this to the 0.100 milestone Jan 31, 2024
t0yv0 added a commit that referenced this issue Feb 2, 2024
Fixes #1595,
https://github.com/pulumi/pulumi/issues/6235

Before this change, refreshing an unchanged resource which used an Asset
or an Archive resulted in polluting Pulumi state with a machine-local
filename.

The simplest example this is tested on is:

```typescript
    const exampleBucketObject = new aws.s3.BucketObject("exampleBucketObject", {
        key: "someobject",
        bucket: bucket.id,
        source: new pulumi.asset.FileAsset(inFile),
    });
```

After this change this example refreshes correctly with no changes
detected.

Unfortunately this change by itself is insufficient to guarantee that
these resources refresh correctly when Pulumi-tracked state is out of
date with respect to the cloud state, and further work is required to
make this correct for individual resources in each provider. For the
example above, the upstream provider for BucketObject does not implement
fetching contents of the object upon Read into a temporary file.
Therefore refreshing the object in this situation updates the "etag"
property but does not guide the user to the need of reconciling the
FileAsset with the updated cloud state.
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed size/S Estimated effort to complete (1-2 days).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants