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

Ensuring the metadata's persisted for the AzureRM backend #16015

Merged
merged 3 commits into from
Sep 6, 2017

Conversation

tombuildsstuff
Copy link
Contributor

After looking into this, it appears if we don't request the current Metadata before putting the Blob Contents - the Metadata is lost; which means that all information needed to unlock the blob is lost. This PR ensures we retrieve the metadata (e.g. lock information) before pushing the file to blob storage - and adds a test to ensure that the metadata is set correctly when altering.

  • Upgrading to v10.3.0-beta of the Azure SDK for Go
  • Upgrading to v8.3.1 beta of AutoRest
  • Loading the Blob MetaData before persisting it

Fixes #16012

Running this test without this fix:

$ TF_ACC=1 envchain azurerm go test ./backend/remote-state/azure/ -v -run=TestPutMaintainsMetaData
=== RUN   TestPutMaintainsMetaData
--- FAIL: TestPutMaintainsMetaData (121.72s)
	backend_test.go:119: creating resource group terraform-backend-testing-4890229005814052142
	backend_test.go:125: creating storage account tfbackendtestingjrxr
	backend_test.go:139: fetching access key for storage account
	backend_test.go:156: creating container terraform
	client_test.go:127: "acceptancetest" was not set to "f3b56bad-33ad-4b93-a600-7a66e9cbd1eb" in the MetaData: map[]
	backend_test.go:173: destroying created resources
	backend_test.go:183: Azure resources destroyed
FAIL
exit status 1
FAIL	github.com/hashicorp/terraform/backend/remote-state/azure	121.746s

after this fix:

$ TF_ACC=1 envchain azurerm go test ./backend/remote-state/azure/ -v -run=TestPutMaintainsMetaData
=== RUN   TestPutMaintainsMetaData
--- PASS: TestPutMaintainsMetaData (137.13s)
	backend_test.go:119: creating resource group terraform-backend-testing-41068478022798168
	backend_test.go:125: creating storage account tfbackendtestingscbr
	backend_test.go:139: fetching access key for storage account
	backend_test.go:156: creating container terraform
	backend_test.go:173: destroying created resources
	backend_test.go:183: Azure resources destroyed
PASS
ok  	github.com/hashicorp/terraform/backend/remote-state/azure	137.153s

jbardin
jbardin previously approved these changes Sep 6, 2017
Copy link
Member

@jbardin jbardin left a comment

Choose a reason for hiding this comment

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

LGTM.
Can we get a full TF_ACC test run output documented here before merging?

@jbardin jbardin dismissed their stale review September 6, 2017 18:47

acceptance test failure

@jbardin
Copy link
Member

jbardin commented Sep 6, 2017

nevermind, Azure ACC tests just need a longer timeout

=== RUN   TestBackend_impl
--- PASS: TestBackend_impl (0.00s)
=== RUN   TestBackendConfig
--- PASS: TestBackendConfig (0.00s)
=== RUN   TestBackend
--- PASS: TestBackend (136.78s)
	backend_test.go:119: creating resource group terraform-backend-testing-4720723530017762978
	backend_test.go:125: creating storage account tfbackendtestingrgut
	backend_test.go:139: fetching access key for storage account
	backend_test.go:156: creating container terraform
	backend_test.go:173: destroying created resources
	backend_test.go:183: Azure resources destroyed
=== RUN   TestBackendLocked
--- PASS: TestBackendLocked (138.23s)
	backend_test.go:119: creating resource group terraform-backend-testing-7551546351769012132
	backend_test.go:125: creating storage account tfbackendtestingtjw3
	backend_test.go:139: fetching access key for storage account
	backend_test.go:156: creating container terraform
	backend_test.go:91: TestBackend: testing state locking for *azure.Backend
	backend_test.go:173: destroying created resources
	backend_test.go:183: Azure resources destroyed
=== RUN   TestRemoteClient_impl
--- PASS: TestRemoteClient_impl (0.00s)
=== RUN   TestRemoteClient
--- PASS: TestRemoteClient (115.10s)
	backend_test.go:119: creating resource group terraform-backend-testing-7006787121995469946
	backend_test.go:125: creating storage account tfbackendtestinga698
	backend_test.go:139: fetching access key for storage account
	backend_test.go:156: creating container terraform
	backend_test.go:173: destroying created resources
	backend_test.go:183: Azure resources destroyed
=== RUN   TestRemoteClientLocks
--- PASS: TestRemoteClientLocks (130.95s)
	backend_test.go:119: creating resource group terraform-backend-testing-5580027579435905588
	backend_test.go:125: creating storage account tfbackendtestingbf9c
	backend_test.go:139: fetching access key for storage account
	backend_test.go:156: creating container terraform
	backend_test.go:173: destroying created resources
	backend_test.go:183: Azure resources destroyed
=== RUN   TestPutMaintainsMetaData
--- PASS: TestPutMaintainsMetaData (129.40s)
	backend_test.go:119: creating resource group terraform-backend-testing-3850395580908544072
	backend_test.go:125: creating storage account tfbackendtestingcp2j
	backend_test.go:139: fetching access key for storage account
	backend_test.go:156: creating container terraform
	backend_test.go:173: destroying created resources
	backend_test.go:183: Azure resources destroyed
PASS

@apparentlymart
Copy link
Contributor

Merging this on behalf of @tombuildsstuff so we can include it in the next release.

@apparentlymart apparentlymart merged commit d074b0d into hashicorp:master Sep 6, 2017
@ghost
Copy link

ghost commented Apr 7, 2020

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 and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.10.3 - Remote state lock release error, every apply
3 participants