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

XRegisterStackTransform called twice for component when not expected to #15972

Closed
Tracked by #12996
zbuchheit opened this issue Apr 17, 2024 · 1 comment
Closed
Tracked by #12996
Assignees
Labels
area/engine Pulumi engine area/transforms Old style SDK based or engine based transforms customer/feedback Feedback from customers customer/lighthouse Lighthouse customer bugs kind/bug Some behavior is incorrect or out of spec resolution/by-design This issue won't be fixed because the functionality is working as designed
Milestone

Comments

@zbuchheit
Copy link

What happened?

While testing XRegisterStackTransform a user experienced the transform func getting called twice on the component. Once with args.Props and once again without args.Props.

Example

Repro Code

import * as pulumi from "@pulumi/pulumi";
import * as awsx from "@pulumi/awsx";

pulumi.runtime.xRegisterStackTransform(args => {
    if (args.type === "awsx:ec2:Vpc") {
    console.log(args.name, args.type, args.props)
    }
    return undefined;
})

const vpc = new awsx.ec2.Vpc("vpc", {
    natGateways: {
        strategy: "None"
    },
});

export const subnet = vpc.vpc.urn;

Repro Steps

  1. Run PULUMI_DEBUG_GRPC=$PWD/preview.json pulumi preview
  2. See the transform is executed twice, also you should see in the grpc logs that RegisterResource is called for the component twice also.

Output of pulumi about

CLI          
Version      3.113.0
Go Version   go1.22.2
Go Compiler  gc

Plugins
NAME    VERSION
aws     6.31.0
awsx    2.7.0
docker  4.5.3
docker  3.6.1
nodejs  unknown

Host     
OS       darwin
Version  14.2.1
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/awsx-ts/dev

Found no resources associated with dev

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/awsx    2.7.0
@pulumi/pulumi  3.113.0
@types/node     18.19.31
typescript      5.4.5
@pulumi/aws     6.31.0

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

Additional context

For some reason if you don't export something you get an error. I will open an issue for that separately.

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 customer/feedback Feedback from customers customer/lighthouse Lighthouse customer bugs labels Apr 17, 2024
@justinvp justinvp removed the needs-triage Needs attention from the triage team label Apr 19, 2024
@justinvp justinvp added this to the 0.103 milestone Apr 19, 2024
@justinvp justinvp added the area/engine Pulumi engine label Apr 19, 2024
@Frassle
Copy link
Member

Frassle commented Apr 19, 2024

There is a design question here to answer here due to how remote component resources work.

The user program makes a RegisterResource call for the component resource, the engine catches this registration and turns it into a Construct call to the component provider. The component provider then sends another real RegisterResource call for the component.

If we transform the inputs on the first Register call then the Construct call gets the transformed arguments to work with, which is probably what's expected. If we transform on the second Register call it just changes what's saved in state for the component.

This also applies to normal components, they do get transformed but it doesn't effect the actual component constructor just what's stored in state (I'm pretty sure this is the same as the old transform system as well).

So I'm not totally sure this is a bug, more just an oddity that you need to be aware of. If we were going to fix this I think the consistent thing to fix would be to not run transforms for any non-remote component registrations.

@Frassle Frassle added the area/transforms Old style SDK based or engine based transforms label Apr 19, 2024
@justinvp justinvp added the resolution/by-design This issue won't be fixed because the functionality is working as designed label May 6, 2024
@justinvp justinvp closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/engine Pulumi engine area/transforms Old style SDK based or engine based transforms customer/feedback Feedback from customers customer/lighthouse Lighthouse customer bugs kind/bug Some behavior is incorrect or out of spec resolution/by-design This issue won't be fixed because the functionality is working as designed
Projects
None yet
Development

No branches or pull requests

3 participants