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

backend/remote: Fix new workspace state migration #28093

Merged
merged 1 commit into from
Mar 16, 2021

Conversation

alisdair
Copy link
Contributor

When migrating state to a new workspace, the version check would error due to a 404 error on fetching the workspace record. This would result in failed state migration.

Instead we should look specifically for a 404 error, and allow migration to continue. If we're just about to create the workspace, there can't be a version incompatibility problem.

Fixes #28092, which was introduced in 0.14.5. Proposing backport to 0.14 and 0.15.

When migrating state to a new workspace, the version check would error
due to a 404 error on fetching the workspace record. This would result
in failed state migration.

Instead we should look specifically for a 404 error, and allow migration
to continue. If we're just about to create the workspace, there can't be
a version incompatibility problem.
@alisdair alisdair added backend/remote 0.14-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged 0.15-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged labels Mar 15, 2021
@alisdair alisdair requested a review from a team March 15, 2021 19:49
@alisdair alisdair self-assigned this Mar 15, 2021
@codecov
Copy link

codecov bot commented Mar 15, 2021

Codecov Report

Merging #28093 (4b15941) into main (34536da) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted Files Coverage Δ
backend/remote/backend.go 62.57% <100.00%> (+0.14%) ⬆️
terraform/node_resource_plan.go 96.11% <0.00%> (-1.95%) ⬇️
states/statefile/version4.go 58.19% <0.00%> (+0.23%) ⬆️

Copy link
Contributor

@apparentlymart apparentlymart left a comment

Choose a reason for hiding this comment

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

This solution makes sense to me! We typically (elsewhere in Terraform) treat a non-existent state snapshot as if it were an empty one (typically by calling states.NewState "just in time"), and this seems consistent with that convention even though not implemented exactly the same way.

@ghost
Copy link

ghost commented Apr 16, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
0.14-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged 0.15-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged backend/remote
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implicit Terraform Cloud workspace creation fails
2 participants