Terraform: lock for consul backend not clearing as expected

Created on 7 Apr 2017  ยท  5Comments  ยท  Source: hashicorp/terraform

Terraform Version

0.9.2

Affected Resource(s)

Consul Backend

Terraform Configuration Files

{
  "terraform": {
    "backend": {
      "consul": {}
    }
  }
}

Expected Behavior

I was expecting the .lock file in consul to be cleared after a successful terraform plan or terraform apply.

Actual Behavior

the lock for that specific path in consul, and thus the .lock file sticks around even after a successful terraform plan or terraform apply.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform init -backend-config=path=<path to key> -backend-config=address=<my-consul-cluster>
  2. terraform plan
  3. Empty state file and .lock is written to Consul
  4. terraform apply
  5. state file is written to Consul, and .lock file still exists

References

I think somebody also posted about this over in the Terraform Google group

backenconsul bug

Most helpful comment

@curratore

I'm not sure what's going on, but your issue doesn't seem related.
The error message: Error message: consul lock was lost is of concern here, since that means the consul client no longer had a lock at the time it was released (which is why the cleanup wasn't done).

Can you open a new issue with any info you may have on how to reproduce this?
Thanks!

All 5 comments

Hi @domofactor! Sorry for the Consul detritus here, and thanks for reporting this.

I think this is the same issue that @jbardin was aiming to fix with #13430, and this fix should be included in the next release of Terraform that will be released soon.

thanks @apparentlymart, i'll wait for that release then. :)

Hello,
I think I have the same issue

Terraform version

0.9.3

Terraform configuration files

terraform {
  backend "consul" {
    address = "consul.backend"
    path    = "tfstate/tfstate-test.tfstate"
    lock    = true
  }
}

Expected behavior

I was expecting the .lock file in consul to be cleared after a successful terraform apply.

Actual behavior

There are 2 files on KV, .lock and .lockinfo

Apply complete! Resources: 42 added, 0 changed, 0 destroyed.

Error releasing the state lock!
Error message: consul lock was lost

Steps to reproduce

  • terraform init Getting the values from environment variables.
  • terraform apply Launching the apply creating tfstate-test.tfstate file and .lock and .lockinfo and finishing the apply successfully but with the releasing error.
  • Check the consul backend and finding tfstate-test.tfstate, .lockand .lockinfo

References

Terraform Google Group
#13430

@curratore

I'm not sure what's going on, but your issue doesn't seem related.
The error message: Error message: consul lock was lost is of concern here, since that means the consul client no longer had a lock at the time it was released (which is why the cleanup wasn't done).

Can you open a new issue with any info you may have on how to reproduce this?
Thanks!

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pawelsawicz picture pawelsawicz  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

shanmugakarna picture shanmugakarna  ยท  3Comments

ketzacoatl picture ketzacoatl  ยท  3Comments

jrnt30 picture jrnt30  ยท  3Comments