terraform-provider-openstack / terraform-provider-openstack

Terraform OpenStack provider
https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs
Mozilla Public License 2.0
379 stars 363 forks source link

PreconditionFailed in swift backend #733

Closed smrcascao closed 1 year ago

smrcascao commented 5 years ago

Hi there,

I'm setting up swift as backend for terraform tfstate. However, I'm always getting a "PrecontionFailed" error message.

Terraform Version

Terraform v0.11.13

Affected Resource(s)

tfstate

Terraform Configuration Files

terraform {
  required_version = "=v0.11.13"
  backend "swift" {
    container         = "terraform_state"
    archive_container = "terraform_state_archive"
  }
}
provider "openstack" {
  version = "1.16"
}

Expected Behavior

tfstate should be persisted in a object-store container

Actual Behavior

tfstate is never persisted and I'm getting a PreconditionFailed error message

kayrus commented 5 years ago

Try to adjust the HCL configuration as stated below:

terraform {
  required_version = "0.11.13"
  backend "swift" {
    container         = "terraform_state"
    archive_container = "terraform_state_archive"
  }
}
provider "openstack" {
  version = "1.16.0"
}

If it doesn't help, make sure that swift containers exist. If they don't, try to create them, e.g.:

$ swift post terraform_state
$ swift post terraform_state_archive
noeliajimenezg commented 5 years ago

I having the same issue using Terraform 0.12 and OpenStack provider 1.19. I run the following tests:

kayrus commented 5 years ago

openstack provider is not responsible to the backend state logic. Try to ask in https://github.com/hashicorp/terraform/pull/20211

rguichard commented 5 years ago

Hi there,

I have also the same issue with the Swift Backend (exact same behavior as @noeliajimenezg), with Terraform 0.11.7 et OpenStack provider 1.19.

However I have also the issue with openstack_objectstorage_container_v1. I use the exact same piece of code as the documentation (https://www.terraform.io/docs/providers/openstack/r/objectstorage_container_v1.html).

If I enable the versioning, I end up with the 412 PreconditionFailed error. The same I have with the Swift Backend.

1 error(s) occurred:

* module.compute.openstack_objectstorage_container_v1.container_1: 1 error(s) occurred:

* openstack_objectstorage_container_v1.container_1: Error creating OpenStack container: Expected HTTP response code [201 202 204] when accessing [PUT http://10.197.214.10:8080/swift/v1/tf-test-container-1], but got 412 instead
{"Code":"PreconditionFailed","BucketName":"tf-test-container-1","RequestId":"tx0000000000000000774c0-005d402805-eb79r6-default","HostId":"eb796-default-default"}

If I don't enable the versioning, it works nicely.

As stated above, if I enable the versioning later, I still end up with the 412.

grok-rv commented 5 years ago

I have same issue as well. I am able to create container terraform_state successfully when used with swift backend. However, it doesn't create the terraform.tf state file in the container. My container shows 0 bytes and object count is 0

I am on openstack provider v1.22 and terraform v0.12.6

provider "openstack" { version = "1.22" }

terraform { required_version = "=v0.12.6" backend "swift" { auth_url = var.authurl user_domain_name = var.domainname region_name = var.regionname tenant_id = var.tenantid user_name = var.username password = var.passwd container = "terraform_state"

} }

grok-rv commented 5 years ago

I did remove archive_container in my configuration as i am receiving pre condition failed in swift backend error after execution

springfan commented 4 years ago

I did remove archive_container in my configuration as i am receiving pre condition failed in swift backend error after execution

Was facing 412 as well. Removnig archive_container fixed the issue on my side as well. Terraform v0.12.24

dejwsz commented 4 years ago

Is it working for anyone? I have "PreconditionFailed" error too.

dejwsz commented 4 years ago

If I remove "archive_container" then it works. So the issue is related to archive container only.

dejwsz commented 4 years ago

So is the versioning working for Swift backend or not? any clue? anyone used it with a success?

dejwsz commented 4 years ago

Hmm, but in your example there is no "archive_container". It works for me with "container" only; "archive_container" turns versioning on. Is it working for you?

śr., 29 lip 2020 o 07:42 springfan notifications@github.com napisał(a):

So is the versioning working for Swift backend or not? any clue? anyone used it with a success?

Yes it work's.

terraform { backend "swift" { container = "my-container-terraform-state" user_domain_name = "yyy" auth_url = "http://xxxxxxxxxx:5000/v3/" region_name = "region-xxxx" tenant_id = "xxxxxxx" } }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/terraform-providers/terraform-provider-openstack/issues/733#issuecomment-665444093, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIXM7AOWGFMU5LUGSWKKCTR56ZDTANCNFSM4HGI6SBQ .

kayrus commented 1 year ago

Thanks to hashicorp for not being interested in swift backend maintainers. Closing this.