Merge branch 'sl1pm4t-fix-taint-w-ignorechanges'
This commit is contained in:
commit
9e9779ebaa
|
@ -1937,6 +1937,51 @@ func TestContext2Plan_taint(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContext2Apply_taintIgnoreChanges(t *testing.T) {
|
||||||
|
m := testModule(t, "plan-taint-ignore-changes")
|
||||||
|
p := testProvider("aws")
|
||||||
|
p.ApplyFn = testApplyFn
|
||||||
|
p.DiffFn = testDiffFn
|
||||||
|
s := &State{
|
||||||
|
Modules: []*ModuleState{
|
||||||
|
&ModuleState{
|
||||||
|
Path: rootModulePath,
|
||||||
|
Resources: map[string]*ResourceState{
|
||||||
|
"aws_instance.foo": &ResourceState{
|
||||||
|
Type: "aws_instance",
|
||||||
|
Primary: &InstanceState{
|
||||||
|
ID: "foo",
|
||||||
|
Attributes: map[string]string{
|
||||||
|
"vars": "foo",
|
||||||
|
"type": "aws_instance",
|
||||||
|
},
|
||||||
|
Tainted: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
ctx := testContext2(t, &ContextOpts{
|
||||||
|
Module: m,
|
||||||
|
Providers: map[string]ResourceProviderFactory{
|
||||||
|
"aws": testProviderFuncFixed(p),
|
||||||
|
},
|
||||||
|
State: s,
|
||||||
|
})
|
||||||
|
|
||||||
|
plan, err := ctx.Plan()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
actual := strings.TrimSpace(plan.String())
|
||||||
|
expected := strings.TrimSpace(testTerraformPlanTaintIgnoreChangesStr)
|
||||||
|
if actual != expected {
|
||||||
|
t.Fatalf("bad:\n%s", actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fails about 50% of the time before the fix for GH-4982, covers the fix.
|
// Fails about 50% of the time before the fix for GH-4982, covers the fix.
|
||||||
func TestContext2Plan_taintDestroyInterpolatedCountRace(t *testing.T) {
|
func TestContext2Plan_taintDestroyInterpolatedCountRace(t *testing.T) {
|
||||||
m := testModule(t, "plan-taint-interpolated-count")
|
m := testModule(t, "plan-taint-interpolated-count")
|
||||||
|
|
|
@ -185,6 +185,12 @@ func (n *EvalDiff) processIgnoreChanges(diff *InstanceDiff) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the resource has been tainted then we don't process ignore changes
|
||||||
|
// since we MUST recreate the entire resource.
|
||||||
|
if diff.DestroyTainted {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
ignorableAttrKeys := make(map[string]bool)
|
ignorableAttrKeys := make(map[string]bool)
|
||||||
for _, ignoredKey := range ignoreChanges {
|
for _, ignoredKey := range ignoreChanges {
|
||||||
for k := range diff.CopyAttributes() {
|
for k := range diff.CopyAttributes() {
|
||||||
|
|
|
@ -1369,6 +1369,21 @@ aws_instance.foo:
|
||||||
num = 2
|
num = 2
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const testTerraformPlanTaintIgnoreChangesStr = `
|
||||||
|
DIFF:
|
||||||
|
|
||||||
|
DESTROY/CREATE: aws_instance.foo
|
||||||
|
type: "" => "aws_instance"
|
||||||
|
vars: "" => "foo"
|
||||||
|
|
||||||
|
STATE:
|
||||||
|
|
||||||
|
aws_instance.foo: (tainted)
|
||||||
|
ID = foo
|
||||||
|
type = aws_instance
|
||||||
|
vars = foo
|
||||||
|
`
|
||||||
|
|
||||||
const testTerraformPlanMultipleTaintStr = `
|
const testTerraformPlanMultipleTaintStr = `
|
||||||
DIFF:
|
DIFF:
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
resource "aws_instance" "foo" {
|
||||||
|
vars = "foo"
|
||||||
|
|
||||||
|
lifecycle {
|
||||||
|
ignore_changes = ["vars"]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue