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
[sdk/go] Track rehydrated components as dependencies #12494
Conversation
Changelog[uncommitted] (2023-03-24)Bug Fixes
|
71ec791
to
663d27a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have a better understanding how the SDK views local components after reading this. I have some nitpicks that should help future readability from the POV of someone trying to skim this for the first time.
When expanding dependencies, local component resources act as aggregations of their descendants; rather than adding the component resource itself, each child resource is added as a dependency. Remote component resources, on the other hand, are added directly to the set, as they naturally act as aggregations of their children with respect to dependencies: the construction of a remote component always waits on the construction of its children. https://github.com/pulumi/pulumi/blob/46ccb5a22caaece6895d828cd019f3886eb7902a/sdk/go/pulumi/rpc.go#L65-L91 However, rehydrated components (i.e. instances of a component resource that have been recreated from a URN, typically via deserialization of a resource reference) won't have any children from the SDK's perspective. And because of that, they aren't currently kept as a dependency. This change fixes rehydrated components to be marked as remote components, in the same way as "dependency resources" are marked as remote components, so that they are kept as a dependency.
663d27a
to
7213365
Compare
Thanks for the feedback! I've addressed your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me. Thanks for updatingmodifying the comments!
bors merge p=1 |
Build succeeded: |
When expanding dependencies, local component resources act as aggregations of their descendants; rather than adding the component resource itself, each child resource is added as a dependency. Remote component resources, on the other hand, are added directly to the set, as they naturally act as aggregations of their children with respect to dependencies: the construction of a remote component always waits on the construction of its children.
pulumi/sdk/go/pulumi/rpc.go
Lines 65 to 91 in 46ccb5a
However, rehydrated components (i.e. instances of a component resource that have been recreated from a URN, typically via deserialization of a resource reference) aren't marked as a remote component and won't have any children from the SDK's perspective. And because of that, when their outputs are used, there won't be any dependencies kept for those outputs.
This change fixes rehydrated components to be marked as remote components, in the same way as "dependency resources" are marked as remote components, so that they are kept as a dependency.
This addresses cases where a component resource method is implemented in Go and the method returns results derived from the component's outputs. Inside the implementation of the provider's
Call
, the implementation will get a rehydrated instance of the component. Without this fix, the dependency on that component will not be kept in the returned output.Here's a concrete example:
pulumi/tests/integration/construct_component_methods/testcomponent-go/main.go
Lines 64 to 68 in 5d3372b
The above is a method implemented in a component provider. The
c *Component
receiver will be a rehydrated instance of the component. The method usespulumi.Sprintf
to create a result that combines some of the component's outputs. But the combined output that is returned won't have the dependency on the component kept, since the rehydrated component is a component and doesn't have any children. With the fix, the dependency will be kept and serialized as expected.Part of #12471