Error: truncate terraform.tfstate: bad file descriptor

Hi,

I am seeing terraform error while creating openstack setup on one of the server. But I am not able to see this error if creating setup in another server by using terraform commands.

After terraform apply seeing this below error

openstack_networking_port_v2.BRANCH2-ports[0]: Creation complete after 6s [id=3684870f-8afa-4199-95e5-70d9713d571b]

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: truncate terraform.tfstate: bad file descriptor

│ Error: Failed to save state

│ Error saving state: truncate terraform.tfstate: bad file descriptor


│ Error: Failed to persist state to backend

│ The error shown above has prevented Terraform from writing the updated state to the configured backend. To allow for recovery,
│ the state has been written to the file “errored.tfstate” in the current working directory.

│ Running “terraform apply” again at this point will create a forked state, making it harder to recover.

│ To retry writing this state, use the following command:
│ terraform state push errored.tfstate

Any ideas on this error will be much appreciated

Hi @Suhasramsai,

I’m not certain what exactly is happening here, but basically what is going on is that the file Terraform opened to store the state is not valid when Terraform goes to save the state. Is it possible that the state file is stored on a read-only filesystem, or a network filesystem that became unavailable while Terraform was executing?