core: Allow planned Update change to become NoOp during apply
This can happen if unknown values in the plan actually end up being identical to the prior values once resolved. In that case, we'll just make no change at all. This is verified by TestContext2Apply_ignoreChangesWithDep.
This commit is contained in:
parent
1885f107a5
commit
2bab5bf502
|
@ -8959,14 +8959,11 @@ func TestContext2Apply_ignoreChangesWithDep(t *testing.T) {
|
||||||
State: s,
|
State: s,
|
||||||
})
|
})
|
||||||
|
|
||||||
if _, diags := ctx.Plan(); diags.HasErrors() {
|
_, diags := ctx.Plan()
|
||||||
t.Fatalf("plan errors: %s", diags.Err())
|
assertNoErrors(t, diags)
|
||||||
}
|
|
||||||
|
|
||||||
state, diags := ctx.Apply()
|
state, diags := ctx.Apply()
|
||||||
if diags.HasErrors() {
|
assertNoErrors(t, diags)
|
||||||
t.Fatalf("diags: %s", diags.Err())
|
|
||||||
}
|
|
||||||
|
|
||||||
actual := strings.TrimSpace(state.String())
|
actual := strings.TrimSpace(state.String())
|
||||||
expected := strings.TrimSpace(s.String())
|
expected := strings.TrimSpace(s.String())
|
||||||
|
|
|
@ -56,15 +56,23 @@ func (n *EvalCheckPlannedChange) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
log.Printf("[TRACE] EvalCheckPlannedChange: Verifying that actual change (action %s) matches planned change (action %s)", actualChange.Action, plannedChange.Action)
|
log.Printf("[TRACE] EvalCheckPlannedChange: Verifying that actual change (action %s) matches planned change (action %s)", actualChange.Action, plannedChange.Action)
|
||||||
|
|
||||||
if plannedChange.Action != actualChange.Action {
|
if plannedChange.Action != actualChange.Action {
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
switch {
|
||||||
tfdiags.Error,
|
case plannedChange.Action == plans.Update && actualChange.Action == plans.NoOp:
|
||||||
"Provider produced inconsistent final plan",
|
// It's okay for an update to become a NoOp once we've filled in
|
||||||
fmt.Sprintf(
|
// all of the unknown values, since the final values might actually
|
||||||
"When expanding the plan for %s to include new values learned so far during apply, provider %q changed the planned action from %s to %s.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.",
|
// match what was there before after all.
|
||||||
absAddr, n.ProviderAddr.ProviderConfig.Type,
|
log.Printf("[DEBUG] After incorporating new values learned so far during apply, %s change has become NoOp", absAddr)
|
||||||
plannedChange.Action, actualChange.Action,
|
default:
|
||||||
),
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
))
|
tfdiags.Error,
|
||||||
|
"Provider produced inconsistent final plan",
|
||||||
|
fmt.Sprintf(
|
||||||
|
"When expanding the plan for %s to include new values learned so far during apply, provider %q changed the planned action from %s to %s.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.",
|
||||||
|
absAddr, n.ProviderAddr.ProviderConfig.Type,
|
||||||
|
plannedChange.Action, actualChange.Action,
|
||||||
|
),
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errs := objchange.AssertObjectCompatible(schema, plannedChange.After, actualChange.After)
|
errs := objchange.AssertObjectCompatible(schema, plannedChange.After, actualChange.After)
|
||||||
|
|
Loading…
Reference in New Issue