-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
stacks: allow unknown variables during apply operations #36311
Conversation
|
||
sort.SliceStable(applyDiags, diagnosticSortFunc(applyDiags)) | ||
expectDiagnosticsForTest(t, applyDiags, | ||
expectDiagnostic( | ||
tfdiags.Error, | ||
"Inconsistent value for input variable during apply", | ||
"The value for non-ephemeral input variable \"input\" was set to a different value during apply than was set during plan. Only ephemeral input variables can change between the plan and apply phases."), | ||
expectDiagnostic(tfdiags.Error, "Invalid inputs for component", "Invalid input variable definition object: attribute \"input\": string required."), |
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.
This is the extra diagnostic discussed in the description. This is the diagnostic that now prevents the bad component from actually applying.
@@ -3110,16 +3117,14 @@ func TestApplyWithChangedInputValues(t *testing.T) { | |||
|
|||
go Apply(ctx, &applyReq, &applyResp) | |||
applyChanges, applyDiags := collectApplyOutput(applyChangesCh, diagsCh) | |||
if len(applyDiags) != 1 { |
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.
this was redundant, we also check the diagnostics on line 3121, so doing it twice was pointless.
Jira ticket created by Sarah: https://hashicorp.atlassian.net/browse/TF-23317 |
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 this logic checks out, and the test case is an accurate reduction of what I understood about how to reproduce the bug we saw.
As mentioned in #36310, I tested a combination of the two PRs, and was able to fully destroy a stack that errored during apply on the first destroy attempt.
An assumption was made in Stacks that unknown variables should not be available at all during apply operations. This assumption was not true - we can have unknown values during refresh, destroy and deferred operations.
This PR removes the part of Stacks that was skipping components that found unknown variables - this was causing endless loops of undestroyable configuration in practice.
This PR also updates the part where variables are loaded for components to allow a specific error to result in a completely unapplyable component. This is the case where a variable has changed between the plan and apply operations. Previously, this was resulting in an unknown value that was just leaving the component to be skipped. Now, we aren't skipping that component anymore so we need to find a way to make that error stronger. This does result in an extra diagnostic being written in this specific error case, but as this error represents a problem in Terraform we should hopefully never see this case in practice.
A side effect of this, is that components with unknown variables now return slightly more complete state updates which has resulted in several tests being updated.