Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: fix bug detecting deeply nested module orphans #5022

Merged

Commits on Feb 9, 2016

  1. core: fix bug detecting deeply nested module orphans

    Context:
    
    As part of building up a Plan, Terraform needs to detect "orphaned"
    resources--resources which are present in the state but not in the
    config. This happens when config for those resources is removed by the
    user, making it Terraform's responsibility to destroy them.
    
    Both state and config are organized by Module into a logical tree, so
    the process of finding orphans involves checking for orphaned Resources
    in the current module and for orphaned Modules, which themselves will
    have all their Resources marked as orphans.
    
    Bug:
    
    In #3114 a problem was exposed where, given a module tree that looked
    like this:
    
    ```
    root
     |
     +-- parent (empty, except for sub-modules)
           |
           +-- child1 (1 resource)
           |
           +-- child2 (1 resource)
    ```
    
    If `parent` was removed, a bunch of error messages would occur during
    the plan. The root cause of this was duplicate orphans appearing for the
    resources in child1 and child2.
    
    Fix:
    
    This turned out to be a bug in orphaned module detection. When looking
    for deeply nested orphaned modules, root.parent was getting added twice
    as an orphaned module to the graph.
    
    Here, we add an additional check to prevent a double add, which
    addresses this scenario properly.
    
    Fixes #3114 (the Provisioner side of it was fixed in #4877)
    phinze committed Feb 9, 2016
    Configuration menu
    Copy the full SHA
    e76fdb9 View commit details
    Browse the repository at this point in the history