Tolerate missing children
This changes our resource creation logic to tolerate missing children.
This ultimately shouldn't be necessary, but we appear to have a bug where
sometimes during deletions we end up with dangling child pointers.  See
pulumi/pulumi#613; it tracks fixing the bug, and also removing this
workaround and reenabling the assertion.
@@ -56,15 +56,19 @@ func makeResourceTreeMap(source []*resource.State) (*Resource, map[resource.URN]
// Next, walk the list of resources, and wire up parents and children. We do this in a second pass so
// that the creation of the tree isn't order dependent.
for _, state := range source {
- for _, childURN := range state.Children {
parentTree, ok := resources[state.URN]
contract.Assertf(ok, "Expected parent resource %s to exist", state.URN)
+ for _, childURN := range state.Children {
childTree, ok := resources[childURN]
- contract.Assertf(ok, "Unexpected missing child %s referred to by parent %s", state.URN, childURN)
+ // BUGBUG[pulumi/pulumi#613]: we should be able to reenable this assert, once we are assured that there
+ // are no dangling child pointers (a bug in the system at the moment).
+ // contract.Assertf(ok, "Unexpected missing child %s referred to by parent %s", childURN, state.URN)
+ if ok {
childTree.Parent = parentTree
parentTree.Children[childTree.State.URN] = childTree
}
}
+ }
// Create a single root node which is the parent of all unparented nodes
root := &Resource{
