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

states/statefile: decode backend hash as uint64 #21484

Merged
merged 1 commit into from
Jun 10, 2019

Conversation

minamijoyo
Copy link
Contributor

Fixes #21478

In #19688, terraform.BackendState.Hash was fixed.
We also need to fix states/statefile.backendStateV2.Hash

before

[terraform@fix-statev2-hash-decode|✔]$ go test -v ./states/statefile -run TestRoundtrip
=== RUN   TestRoundtrip
=== RUN   TestRoundtrip/v1-simple
2019/05/28 23:58:38 [TRACE] statefile.Read: upgrading format from v1 to v2
2019/05/28 23:58:38 [STATE UPGRADE] Detected the following collections in state: [triggers.]
2019/05/28 23:58:38 [STATE UPGRADE] Detected triggers as a map. Replaced count = 1
2019/05/28 23:58:38 [STATE UPGRADE] Detected the following collections in state: [triggers.]
2019/05/28 23:58:38 [STATE UPGRADE] Detected triggers as a map. Replaced count = 1
2019/05/28 23:58:38 [STATE UPGRADE] Detected the following collections in state: [triggers.]
2019/05/28 23:58:38 [STATE UPGRADE] Detected triggers as a map. Replaced count = 1
=== RUN   TestRoundtrip/v3-bigint
=== RUN   TestRoundtrip/v3-grabbag
=== RUN   TestRoundtrip/v3-simple
=== RUN   TestRoundtrip/v4-simple
--- FAIL: TestRoundtrip (0.01s)
    --- PASS: TestRoundtrip/v1-simple (0.00s)
    --- FAIL: TestRoundtrip/v3-bigint (0.00s)
        roundtrip_test.go:53: unexpected error: Invalid state file format: The state file field "hash" has invalid value number 10669755453527594976
    --- PASS: TestRoundtrip/v3-grabbag (0.00s)
    --- PASS: TestRoundtrip/v3-simple (0.00s)
    --- PASS: TestRoundtrip/v4-simple (0.00s)
FAIL
FAIL    github.com/hashicorp/terraform/states/statefile 0.024s

after

[terraform@fix-statev2-hash-decode|✔]$ go test -v ./states/statefile -run TestRoundtrip
=== RUN   TestRoundtrip
=== RUN   TestRoundtrip/v1-simple
2019/05/28 23:57:07 [TRACE] statefile.Read: upgrading format from v1 to v2
2019/05/28 23:57:07 [STATE UPGRADE] Detected the following collections in state: [triggers.]
2019/05/28 23:57:07 [STATE UPGRADE] Detected triggers as a map. Replaced count = 1
2019/05/28 23:57:07 [STATE UPGRADE] Detected the following collections in state: [triggers.]
2019/05/28 23:57:07 [STATE UPGRADE] Detected triggers as a map. Replaced count = 1
2019/05/28 23:57:07 [STATE UPGRADE] Detected the following collections in state: [triggers.]
2019/05/28 23:57:07 [STATE UPGRADE] Detected triggers as a map. Replaced count = 1
=== RUN   TestRoundtrip/v3-bigint
=== RUN   TestRoundtrip/v3-grabbag
=== RUN   TestRoundtrip/v3-simple
=== RUN   TestRoundtrip/v4-simple
--- PASS: TestRoundtrip (0.01s)
    --- PASS: TestRoundtrip/v1-simple (0.00s)
    --- PASS: TestRoundtrip/v3-bigint (0.00s)
    --- PASS: TestRoundtrip/v3-grabbag (0.00s)
    --- PASS: TestRoundtrip/v3-simple (0.00s)
    --- PASS: TestRoundtrip/v4-simple (0.00s)
PASS
ok      github.com/hashicorp/terraform/states/statefile (cached)

Fixes hashicorp#21478

In hashicorp#19688, `terraform.BackendState.Hash` was fixed.
We also need to fix `states/statefile.backendStateV2.Hash`
"lineage": "0f5b2ff9-6ff5-8e9e-1f81-aa3ce9a483eb",
"backend": {
"hash": 10669755453527594976
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file was copied from v3-grabbag.in.tfstate and the following lines are added.

[terraform@fix-statev2-hash-decode|✔]$ diff -u states/statefile/testdata/roundtrip/{v3-grabbag.in.tfstate,v3-bigint.in.tfstate}
--- states/statefile/testdata/roundtrip/v3-grabbag.in.tfstate   2018-12-13 11:18:13.000000000 +0900
+++ states/statefile/testdata/roundtrip/v3-bigint.in.tfstate    2019-05-28 23:56:58.000000000 +0900
@@ -3,6 +3,9 @@
     "terraform_version": "0.11.1",
     "serial": 8,
     "lineage": "0f5b2ff9-6ff5-8e9e-1f81-aa3ce9a483eb",
+    "backend": {
+        "hash": 10669755453527594976
+    },
     "modules": [
         {
             "path": [

@@ -0,0 +1,97 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file was only copied from v3-grabbag.out.tfstate

@pselle pselle modified the milestones: v0.12.1, TBD Jun 4, 2019
@jbardin jbardin merged commit 2988e37 into hashicorp:master Jun 10, 2019
hinling-whistle pushed a commit to WhistleLabs/dockerfile-ci that referenced this pull request Jun 24, 2019
akatrevorjay pushed a commit to WhistleLabs/dockerfile-ci that referenced this pull request Jun 24, 2019
* [DEVOPS-1997] -- update covalence build to 0.8.3

* [DEVOPS-2353] -- upgrade terraform to 0.12.2 to have this fix: hashicorp/terraform#21484
hinling-whistle added a commit to WhistleLabs/dockerfile-ci that referenced this pull request Jun 25, 2019
…ci build config.yml (#41)

* [DEVOPS-1997] -- update covalence build to 0.8.3

* [DEVOPS-2353] -- upgrade terraform to 0.12.2 to have this fix: hashicorp/terraform#21484

* [DEVOPS-2353] -- forgot to update the terraform version in the circle ci build config.yml
@ghost
Copy link

ghost commented Jul 25, 2019

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 Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants