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

don't lose checks from refresh-only plan #32115

Merged
merged 1 commit into from Nov 2, 2022
Merged

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Oct 28, 2022

If there are no changes in a given plan, then there is no reason to create and walk a full apply graph since all objects are known. This means that an apply operation of a refresh plan should only entail returning the planned state.

We however do still need the walk to apply output changes which are recorded in the plan, and some vestigial cleanup is done during the apply walk. In the future, copying the planned output values and cleaning up the state could be done outside the walk, but we will leave that for later pending investigation into any other unexpected side effects it may cause.

For now to ensure refreshed checks are stored correctly, copy the planned checks into the final state after the apply walk.

@jbardin jbardin added the 1.3-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Oct 28, 2022
@jbardin jbardin requested a review from a team October 28, 2022 19:12
@@ -25,6 +25,10 @@ func (c *Context) Apply(plan *plans.Plan, config *configs.Config) (*states.State

log.Printf("[DEBUG] Building and walking apply graph for %s plan", plan.UIMode)

// FIXME: refresh plans still store outputs as changes, so we can't use
// Empty()
possibleRefresh := len(plan.Changes.Resources) == 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth considering using plan.UIMode == plans.RefreshOnlyMode as the condition here instead of looking at resource changes? The UIMode field does have a "do not use for apply-time logic" warning, so that's rude, but if the goal is detecting a refresh-only plan for this temporary fix maybe that's okay to ignore.

I can't point definitively to an example of how things could go wrong, but my concern is that there might somehow be a non-refresh plan which causes changes to checks without having any resource changes, and we'd be incorrectly recording the checks in state in that case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also can't imagine how that could go wrong, but I agree the UIMode feels slightly more robust. We've committed to using UIMode for the time being because of destroy plan differences, so using it again here isn't going to cause any more problems.

@jbardin jbardin requested review from a team as code owners November 2, 2022 14:55
@jbardin jbardin removed request for a team November 2, 2022 14:56
@jbardin
Copy link
Member Author

jbardin commented Nov 2, 2022

Since the original commits ended up included in #32123, I rebased this to only include the final commit from review to clean things up.

@github-actions
Copy link

github-actions bot commented Nov 2, 2022

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

@github-actions
Copy link

github-actions bot commented Dec 3, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.3-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants