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

Make the pre-destroy refresh a full plan #32208

Merged
merged 1 commit into from Nov 17, 2022
Merged

Commits on Nov 11, 2022

  1. Make the pre-destroy refresh a full plan

    In order to complete the terraform destroy command, a refresh must first
    be done to update state and remove any instances which have already been
    deleted externally. This was being done with a refresh plan, which will
    avoid any condition evaluations and avoid planning new instances. That
    however can fail due to invalid references from resources that are
    already missing from the state.
    
    A new plan type to handle the concept of the pre-destroy-refresh is
    needed here, which should probably be incorporated directly into the
    destroy plan, just like the original refresh walk was incorporated into
    the normal planning process. That however is major refactoring that is
    not appropriate for a patch release.
    
    Instead we make two discrete changes here to prevent blocking a destroy
    plan. The first is to use a normal plan to refresh, which will enable
    evaluation because missing and inconsistent instances will be planned
    for creation and updates, allowing them to be evaluated. That is not
    optimal of course, but does revert to the method used by previous
    Terraform releases until a better method can be implemented.
    
    The second change is adding a preDestroyRefresh flag to the planning
    process. This is checked in any location which evalCheckRules is called,
    and lets us change the diagnosticSeverity of the output to only be
    warnings, matching the behavior of a normal refresh plan.
    jbardin committed Nov 11, 2022
    Copy the full SHA
    3ea704e View commit details
    Browse the repository at this point in the history