fix: restore plans from the external store when the pull dir has none - #6813
Open
SaiPisey2 wants to merge 1 commit into
Open
fix: restore plans from the external store when the pull dir has none#6813SaiPisey2 wants to merge 1 commit into
SaiPisey2 wants to merge 1 commit into
Conversation
buildAllProjectCommandsByPlan only restored plans from the external store when the pull directory was absent. If the directory existed but held no plan files, the apply failed with "plan file is missing ... run atlantis plan" even though the plan was in the store. That happens whenever an earlier event created the directory on this replica, including after deletePlansAndPlanLocks removes the .tfplan of a failed autoplan, and it is the normal case with more than one replica, where an apply can land on a replica that never held the plan. Attempt the restore when the plan finder comes back empty as well, and share the restore path between both cases. Signed-off-by: SaiPisey2 <piseysai0202@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
what
buildAllProjectCommandsByPlannow also tries the external plan store when the pull directory exists butPendingPlanFinderfinds no plans in it, not only when the directory is missing entirely.RestorePlans) moves intorestorePlansFromStoreand is shared by both cases.why
os.IsNotExistbranch. If the directory was present but empty of plans, apply failed withplan file is missing for dir "..." workspace "..." with status "planned"; run atlantis plan, even though the plan was in the store andPullStatussaidplanned.deletePlansAndPlanLocksremoves the.tfplanof an autoplan that failed for an unrelated reason, leaving the directory behind.os.ErrNotExist), the empty plan list is kept so the existing "plan file is missing" error is still what the user sees. Stores that cannot restore, such asLocalPlanStore, are skipped by the capability probe as before, so this is a no-op without--enable-external-stores.tests
TestDefaultProjectCommandBuilder_ExternalPlanStoreRecoveryPullDirWithoutPlans: the pull dir exists as a git repo with no.tfplan, andRestorePlanswrites the plan back. Without the change the test fails with the exact error from the issue —plan file is missing for dir "project1" workspace "default" project "" with status "planned"— and passes with it.go build ./...andgo test ./server/events/...pass on darwin/arm64. The existing recovery tests, including the ones covering clone-before-restore ordering for non-default workspaces, are unchanged and still pass.references