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/COS: remove COS object lock tag either when unlock remote state #31223

Merged
merged 1 commit into from Jun 14, 2022

Conversation

Kagashino
Copy link
Contributor

@Kagashino Kagashino commented Jun 10, 2022

When running command terraform force-unlock , the remote state file will be removed as expect. However, the tencentcloud-terraform-lock tag will not removed at the same time in some unexpected program exit cases. Creating this PR is purpose to ensure the tag removed to get rid of impact of next terraform operation.

Here shows the unit test output:

$ TF_ACC=1 go test -v ./internal/backend/remote-state/cos

=== RUN   TestStateFile
=== PAUSE TestStateFile
=== RUN   TestRemoteClient
=== PAUSE TestRemoteClient
=== RUN   TestRemoteClientWithPrefix
=== PAUSE TestRemoteClientWithPrefix
=== RUN   TestRemoteClientWithEncryption
=== PAUSE TestRemoteClientWithEncryption
=== RUN   TestRemoteLocks
=== PAUSE TestRemoteLocks
=== RUN   TestBackend
=== PAUSE TestBackend
=== RUN   TestBackendWithPrefix
=== PAUSE TestBackendWithPrefix
=== RUN   TestBackendWithEncryption
=== PAUSE TestBackendWithEncryption
=== CONT  TestBackendWithPrefix
=== CONT  TestStateFile
=== RUN   TestStateFile/_default.tfstate_default
=== CONT  TestBackend
=== RUN   TestStateFile/_test.tfstate_default
=== RUN   TestStateFile/_test.tfstate_dev
=== RUN   TestStateFile/terraform/test_default.tfstate_default
=== CONT  TestRemoteLocks
=== CONT  TestRemoteClientWithEncryption
=== CONT  TestRemoteClientWithPrefix
=== CONT  TestRemoteClient
=== CONT  TestBackendWithEncryption
=== CONT  TestBackend
=== CONT  TestBackendWithPrefix
=== CONT  TestRemoteClientWithPrefix
=== CONT  TestBackendWithEncryption
=== CONT  TestRemoteClient
=== RUN   TestStateFile/terraform/test_test.tfstate_default
=== CONT  TestRemoteClientWithEncryption
=== CONT  TestRemoteLocks
=== RUN   TestStateFile/terraform/test_test.tfstate_dev
--- PASS: TestStateFile (0.00s)
    --- PASS: TestStateFile/_default.tfstate_default (0.00s)
    --- PASS: TestStateFile/_test.tfstate_default (0.00s)
    --- PASS: TestStateFile/_test.tfstate_dev (0.00s)
    --- PASS: TestStateFile/terraform/test_default.tfstate_default (0.00s)
    --- PASS: TestStateFile/terraform/test_test.tfstate_default (0.00s)
    --- PASS: TestStateFile/terraform/test_test.tfstate_dev (0.00s)
=== CONT  TestBackendWithPrefix
=== CONT  TestBackendWithEncryption
=== CONT  TestBackend
--- PASS: TestRemoteClientWithPrefix (1.79s)
--- PASS: TestRemoteClientWithEncryption (1.84s)
--- PASS: TestRemoteClient (1.90s)
--- PASS: TestRemoteLocks (3.25s)
=== CONT  TestBackend
=== CONT  TestBackendWithEncryption
=== CONT  TestBackendWithPrefix
=== CONT  TestBackend
    testing.go:300: TestBackend: testing state locking for *cos.Backend
=== CONT  TestBackendWithEncryption
    testing.go:300: TestBackend: testing state locking for *cos.Backend
=== CONT  TestBackendWithPrefix
    testing.go:300: TestBackend: testing state locking for *cos.Backend
=== CONT  TestBackend
    testing.go:300: TestBackend: testing state locking for *cos.Backend
--- PASS: TestBackendWithEncryption (6.95s)
--- PASS: TestBackendWithPrefix (7.01s)
--- PASS: TestBackend (9.15s)
PASS
ok      github.com/hashicorp/terraform/internal/backend/remote-state/cos        9.532s

@crw
Copy link
Collaborator

crw commented Jun 10, 2022

Thanks for this submission! Just a note that there is a general hold on backend reviews (see CONTRIBUTING.md#state-storage-backends. I will update this PR if/when that is lifted.

I see that @likexian is listed as the maintainer of this backend in CODEOWNERS. We would need a review from @likexian before moving forward. However, given the above hold on reviews, we cannot guarantee the core team will be able to review it in the near future.

Thanks again for your submission!

@likexian
Copy link
Contributor

Hello @crw
LGTM

@jbardin jbardin self-assigned this Jun 13, 2022
@jbardin
Copy link
Member

jbardin commented Jun 13, 2022

Thanks @likexian!

@jbardin jbardin added the 1.2-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Jun 14, 2022
@jbardin jbardin merged commit e7e3d80 into hashicorp:main Jun 14, 2022
@github-actions
Copy link

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

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 Jul 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.2-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged backend/cos enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants