terraform: fix create before destroy edge case with partial state
This commit is contained in:
parent
f7f1f17b49
commit
33cad6d207
|
@ -3424,8 +3424,7 @@ func TestContext2Apply_provisionerFail_createBeforeDestroy(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestContextApply_error_createBeforeDestroy(t *testing.T) {
|
||||
func TestContext2Apply_error_createBeforeDestroy(t *testing.T) {
|
||||
m := testModule(t, "apply-error-create-before")
|
||||
p := testProvider("aws")
|
||||
state := &State{
|
||||
|
@ -3446,7 +3445,7 @@ func TestContextApply_error_createBeforeDestroy(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
|
@ -3470,10 +3469,11 @@ func TestContextApply_error_createBeforeDestroy(t *testing.T) {
|
|||
actual := strings.TrimSpace(state.String())
|
||||
expected := strings.TrimSpace(testTerraformApplyErrorCreateBeforeDestroyStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: \n%s\n\n\n%s", actual, expected)
|
||||
t.Fatalf("bad: \n%s\n\nExpected:\n\n%s", actual, expected)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestContextApply_errorDestroy_createBeforeDestroy(t *testing.T) {
|
||||
m := testModule(t, "apply-error-create-before")
|
||||
p := testProvider("aws")
|
||||
|
|
|
@ -103,6 +103,8 @@ func (n *EvalWriteState) Eval(
|
|||
rs.Type = n.ResourceType
|
||||
rs.Dependencies = n.Dependencies
|
||||
|
||||
println(fmt.Sprintf("%#v", rs))
|
||||
println(fmt.Sprintf("%#v", *n.State))
|
||||
if n.Tainted != nil && *n.Tainted {
|
||||
if n.TaintedIndex != -1 {
|
||||
rs.Tainted[n.TaintedIndex] = *n.State
|
||||
|
|
|
@ -315,8 +315,9 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode {
|
|||
},
|
||||
&EvalIf{
|
||||
If: func(ctx EvalContext) (bool, error) {
|
||||
return n.Resource.Lifecycle.CreateBeforeDestroy &&
|
||||
tainted, nil
|
||||
failure := tainted || err != nil
|
||||
tainted = n.Resource.Lifecycle.CreateBeforeDestroy
|
||||
return n.Resource.Lifecycle.CreateBeforeDestroy && failure, nil
|
||||
},
|
||||
Node: &EvalUndeposeState{
|
||||
Name: n.stateId(),
|
||||
|
|
Loading…
Reference in New Issue