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 TestContext2Apply_error_createBeforeDestroy(t *testing.T) {
|
||||||
func TestContextApply_error_createBeforeDestroy(t *testing.T) {
|
|
||||||
m := testModule(t, "apply-error-create-before")
|
m := testModule(t, "apply-error-create-before")
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
state := &State{
|
state := &State{
|
||||||
|
@ -3446,7 +3445,7 @@ func TestContextApply_error_createBeforeDestroy(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ctx := testContext(t, &ContextOpts{
|
ctx := testContext2(t, &ContextOpts{
|
||||||
Module: m,
|
Module: m,
|
||||||
Providers: map[string]ResourceProviderFactory{
|
Providers: map[string]ResourceProviderFactory{
|
||||||
"aws": testProviderFuncFixed(p),
|
"aws": testProviderFuncFixed(p),
|
||||||
|
@ -3470,10 +3469,11 @@ func TestContextApply_error_createBeforeDestroy(t *testing.T) {
|
||||||
actual := strings.TrimSpace(state.String())
|
actual := strings.TrimSpace(state.String())
|
||||||
expected := strings.TrimSpace(testTerraformApplyErrorCreateBeforeDestroyStr)
|
expected := strings.TrimSpace(testTerraformApplyErrorCreateBeforeDestroyStr)
|
||||||
if actual != expected {
|
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) {
|
func TestContextApply_errorDestroy_createBeforeDestroy(t *testing.T) {
|
||||||
m := testModule(t, "apply-error-create-before")
|
m := testModule(t, "apply-error-create-before")
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
|
|
|
@ -103,6 +103,8 @@ func (n *EvalWriteState) Eval(
|
||||||
rs.Type = n.ResourceType
|
rs.Type = n.ResourceType
|
||||||
rs.Dependencies = n.Dependencies
|
rs.Dependencies = n.Dependencies
|
||||||
|
|
||||||
|
println(fmt.Sprintf("%#v", rs))
|
||||||
|
println(fmt.Sprintf("%#v", *n.State))
|
||||||
if n.Tainted != nil && *n.Tainted {
|
if n.Tainted != nil && *n.Tainted {
|
||||||
if n.TaintedIndex != -1 {
|
if n.TaintedIndex != -1 {
|
||||||
rs.Tainted[n.TaintedIndex] = *n.State
|
rs.Tainted[n.TaintedIndex] = *n.State
|
||||||
|
|
|
@ -315,8 +315,9 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode {
|
||||||
},
|
},
|
||||||
&EvalIf{
|
&EvalIf{
|
||||||
If: func(ctx EvalContext) (bool, error) {
|
If: func(ctx EvalContext) (bool, error) {
|
||||||
return n.Resource.Lifecycle.CreateBeforeDestroy &&
|
failure := tainted || err != nil
|
||||||
tainted, nil
|
tainted = n.Resource.Lifecycle.CreateBeforeDestroy
|
||||||
|
return n.Resource.Lifecycle.CreateBeforeDestroy && failure, nil
|
||||||
},
|
},
|
||||||
Node: &EvalUndeposeState{
|
Node: &EvalUndeposeState{
|
||||||
Name: n.stateId(),
|
Name: n.stateId(),
|
||||||
|
|
Loading…
Reference in New Issue