terraform: fix issues with tainted marking

This commit is contained in:
Mitchell Hashimoto 2014-07-24 08:49:29 -07:00
parent 62511c0ccb
commit 86903eb18f
2 changed files with 7 additions and 0 deletions

View File

@ -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
}

View File

@ -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