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

connect references from config nodes during apply #33403

Merged
merged 2 commits into from
Jun 28, 2023

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Jun 20, 2023

In order to ensure that transitive dependencies are connected even when there are no instances for a resource, we need to route the references through the config ("expand") node. This happens naturally by having the expand node report its config references, however legacy configs can contain self-references without the "self" identifier, so those need to be filtered out.

We can also remove the old NodeApplyableResource type, which was only there to call writeResourceState and can be done by nodeExpandApplyableResource without the expansion (the "Expand" node name in this context refers to the setting of the instances.Expander, not DynamicExpand)

Fixes #33370

@jbardin jbardin requested a review from a team June 20, 2023 20:40
@@ -6463,7 +6463,7 @@ func TestContext2Apply_errorCreateInvalidNew(t *testing.T) {
if got, want := diags.Err().Error(), "forced error"; !strings.Contains(got, want) {
t.Errorf("returned error does not contain %q, but it should\n%s", want, diags.Err())
}
if got, want := len(state.RootModule().Resources), 2; got != want {
if got, want := len(state.RootModule().Resources), 1; got != want {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is because there is no empty resource record in state now that the expand node is part of the instance ordering

In order to ensure that transitive dependencies are connected even when
there are no instances for a resource, we need to route the references
through the config ("expand") node. This happens naturally by having the
expand node report its config references, however legacy configs can
contain self-referenced without the "self" identifier, so those need to
be filtered out.
Move the logic for NodeApplyableResource into
nodeExpandApplyableResource to remove an unnecessary level of expansion.
@jbardin jbardin force-pushed the jbardin/deps-with-no-instances branch from e320507 to bb0bb7a Compare June 28, 2023 17:32
@jbardin jbardin merged commit 3fcf16f into main Jun 28, 2023
4 checks passed
@jbardin jbardin deleted the jbardin/deps-with-no-instances branch June 28, 2023 18:00
@github-actions
Copy link

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

transitive dependencies can be missed when there are no instances to apply
3 participants