From 86903eb18fa26084cc3d44487c6a79797836439a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 24 Jul 2014 08:49:29 -0700 Subject: [PATCH] terraform: fix issues with tainted marking --- terraform/context.go | 4 ++++ terraform/state.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/terraform/context.go b/terraform/context.go index d088da574..eed5ecc46 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -592,6 +592,8 @@ func (c *Context) applyWalkFn() depgraph.WalkFunc { } if tainted { + log.Printf("[DEBUG] %s: Marking as tainted", r.Id) + c.sl.Lock() c.state.Tainted[r.Id] = struct{}{} c.sl.Unlock() @@ -599,6 +601,7 @@ func (c *Context) applyWalkFn() depgraph.WalkFunc { // Update the state for the resource itself r.State = rs + r.Tainted = tainted for _, h := range c.hooks { handleHook(h.PostApply(r.Id, r.State, applyerr)) @@ -721,6 +724,7 @@ func (c *Context) planWalkFn(result *Plan) depgraph.WalkFunc { if r.Tainted { // Tainted resources must also be destroyed + log.Printf("[DEBUG] %s: Tainted, marking for destroy", r.Id) diff.Destroy = true } diff --git a/terraform/state.go b/terraform/state.go index bd2767d5c..c9812abdb 100644 --- a/terraform/state.go +++ b/terraform/state.go @@ -42,6 +42,9 @@ func (s *State) deepcopy() *State { for k, v := range s.Resources { result.Resources[k] = v } + for k, v := range s.Tainted { + result.Tainted[k] = v + } } return result