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

Investigate the need to re-plan the resource outputs in Update if a resource is going to be replaced #2672

Open
VenelinMartinov opened this issue Nov 26, 2024 · 0 comments
Labels
kind/engineering Work that is not visible to an external user

Comments

@VenelinMartinov
Copy link
Contributor

What happened?

During the work on detailed diff we discovered that we are not correctly marking fully computed properties for re-computation when a resource is replaced: #2660

A similar issue might affect Update - it does not call Plan twice, so it likely also fails to correctly mark computed properties as Unknown if the resource is going to get replaced. This likely has an effect on the correctness of the preview when previewing changes, as the engine does not find out that certain inputs to resources might change.

The other possibility is that the engine is conservative about this and always marks a dependent resource for replacement. In that case perhaps this is fine?

Example

A similar setup to #2660 but what would happen if a secondary resource uses the fully computed ID property of the primary resource as an input. The secondary resource should also get marked for replacement.

If we transition from: properties: {} to properties: {key: "value"} for the PF schema

rschema.Schema{
	Attributes: map[string]rschema.Attribute{
		"key": rschema.StringAttribute{
			Optional:      true,
			PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
		},
		"id": rschema.StringAttribute{
			Computed: true,
			PlanModifiers: []planmodifier.String{
				stringplanmodifier.UseStateForUnknown(),
			},
		},
	},
}

We get:

	pulumiOut: `Previewing update (test):
  pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
    +-testprovider:index/test:Test: (replace)
        [id=test-id]
        [urn=urn:pulumi:test::project::testprovider:index/test:Test::p]
      + key: "value"
Resources:
    +-1 to replace
    1 unchanged

versus

  # testprovider_test.res must be replaced
+/- resource "testprovider_test" "res" {
      ~ id  = "test-id" -> (known after apply)
      + key = "value" # forces replacement
    }

Output of pulumi about

.

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

@VenelinMartinov VenelinMartinov added the kind/engineering Work that is not visible to an external user label Nov 26, 2024
@pulumi-bot pulumi-bot added the needs-triage Needs attention from the triage team label Nov 26, 2024
@VenelinMartinov VenelinMartinov changed the title Investigate the need to re-plan the resource outputs if a resource is going to be replaced in Update Investigate the need to re-plan the resource outputs in Update if a resource is going to be replaced Nov 26, 2024
@VenelinMartinov VenelinMartinov removed the needs-triage Needs attention from the triage team label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/engineering Work that is not visible to an external user
Projects
None yet
Development

No branches or pull requests

2 participants