terraform: tainted things all work
This commit is contained in:
parent
10b5661bc3
commit
06c862a379
|
@ -620,8 +620,13 @@ func (c *Context) applyWalkFn() depgraph.WalkFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the primary instance
|
if r.Tainted && r.TaintedIndex > -1 {
|
||||||
r.State.Primary = is
|
// Update the tainted resource.
|
||||||
|
r.State.Tainted[r.TaintedIndex] = is
|
||||||
|
} else {
|
||||||
|
// Update the primary resource
|
||||||
|
r.State.Primary = is
|
||||||
|
}
|
||||||
|
|
||||||
// Update the resulting diff
|
// Update the resulting diff
|
||||||
c.sl.Lock()
|
c.sl.Lock()
|
||||||
|
@ -760,7 +765,7 @@ func (c *Context) planWalkFn(result *Plan) depgraph.WalkFunc {
|
||||||
|
|
||||||
cb := func(r *Resource) error {
|
cb := func(r *Resource) error {
|
||||||
if r.Tainted && r.TaintedIndex > -1 {
|
if r.Tainted && r.TaintedIndex > -1 {
|
||||||
// No-op this. We somewhat magically diff this later.
|
// We don't diff tainted resources.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,7 +812,7 @@ func (c *Context) planWalkFn(result *Plan) depgraph.WalkFunc {
|
||||||
if r.Tainted {
|
if r.Tainted {
|
||||||
// Tainted resources must also be destroyed
|
// Tainted resources must also be destroyed
|
||||||
log.Printf("[DEBUG] %s: Tainted, marking for destroy", r.Id)
|
log.Printf("[DEBUG] %s: Tainted, marking for destroy", r.Id)
|
||||||
diff.Destroy = true
|
diff.DestroyTainted = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if diff.RequiresNew() && is != nil && is.ID != "" {
|
if diff.RequiresNew() && is != nil && is.ID != "" {
|
||||||
|
|
|
@ -99,7 +99,7 @@ func (d *Diff) String() string {
|
||||||
rdiff := d.Resources[name]
|
rdiff := d.Resources[name]
|
||||||
|
|
||||||
crud := "UPDATE"
|
crud := "UPDATE"
|
||||||
if rdiff.RequiresNew() && rdiff.Destroy {
|
if rdiff.RequiresNew() && (rdiff.Destroy || rdiff.DestroyTainted) {
|
||||||
crud = "DESTROY/CREATE"
|
crud = "DESTROY/CREATE"
|
||||||
} else if rdiff.Destroy {
|
} else if rdiff.Destroy {
|
||||||
crud = "DESTROY"
|
crud = "DESTROY"
|
||||||
|
@ -154,8 +154,9 @@ func (d *Diff) String() string {
|
||||||
|
|
||||||
// InstanceDiff is the diff of a resource from some state to another.
|
// InstanceDiff is the diff of a resource from some state to another.
|
||||||
type InstanceDiff struct {
|
type InstanceDiff struct {
|
||||||
Attributes map[string]*ResourceAttrDiff
|
Attributes map[string]*ResourceAttrDiff
|
||||||
Destroy bool
|
Destroy bool
|
||||||
|
DestroyTainted bool
|
||||||
|
|
||||||
once sync.Once
|
once sync.Once
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,6 +338,9 @@ func graphAddDiff(g *depgraph.Graph, d *Diff) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if rn.Resource.Tainted && rn.Resource.TaintedIndex > -1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
rd, ok := d.Resources[rn.Resource.Id]
|
rd, ok := d.Resources[rn.Resource.Id]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
Loading…
Reference in New Issue