deposed instances should not be counted as orphans

Do not add orphan nodes for resources that only contain deposed
instances.
This commit is contained in:
James Bardin 2021-05-20 09:36:45 -04:00
parent aaaeeffa81
commit 95e788f13b
2 changed files with 26 additions and 1 deletions

View File

@ -79,7 +79,12 @@ func (t *OrphanResourceInstanceTransformer) transform(g *Graph, ms *states.Modul
}
}
for key := range rs.Instances {
for key, inst := range rs.Instances {
// deposed instances will be taken care of separately
if inst.Current == nil {
continue
}
addr := rs.Addr.Instance(key)
abstract := NewNodeAbstractResourceInstance(addr)
var node dag.Vertex = abstract

View File

@ -50,6 +50,26 @@ func TestOrphanResourceInstanceTransformer(t *testing.T) {
Module: addrs.RootModule,
},
)
// A deposed orphan should not be handled by this transformer
s.SetResourceInstanceDeposed(
addrs.Resource{
Mode: addrs.ManagedResourceMode,
Type: "test_instance",
Name: "deposed",
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
states.NewDeposedKey(),
&states.ResourceInstanceObjectSrc{
AttrsFlat: map[string]string{
"id": "foo",
},
Status: states.ObjectReady,
},
addrs.AbsProviderConfig{
Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule,
},
)
})
g := Graph{Path: addrs.RootModuleInstance}