use CreateBeforeDestroy from state

If the resource was stored as CreateBeforeDestroy, use the same ordering
regardless.

This reversal will be taken care if more cleanly in state-only destroys,
and with less risk. Don't use this commit as-is.
This commit is contained in:
James Bardin 2019-12-12 15:03:32 -05:00
parent a44cf03eaa
commit 691bb6b907
1 changed files with 13 additions and 4 deletions

View File

@ -56,12 +56,21 @@ func (n *NodeDestroyResourceInstance) CreateBeforeDestroy() bool {
return *n.CreateBeforeDestroyOverride
}
// If we have no config, we just assume no
if n.Config == nil || n.Config.Managed == nil {
return false
// Config takes precedence
if n.Config != nil && n.Config.Managed != nil {
return n.Config.Managed.CreateBeforeDestroy
}
return n.Config.Managed.CreateBeforeDestroy
// Otherwise check the state for a stored destroy order
if rs := n.ResourceState; rs != nil {
if s := rs.Instance(n.InstanceKey); s != nil {
if s.Current != nil {
return s.Current.CreateBeforeDestroy
}
}
}
return false
}
// GraphNodeDestroyerCBD