简体   繁体   English

无法在 GCP 后端释放 Terraform 状态锁

[英]Terraform state lock not able to release in GCP backend

While running terraform in automation ie CI/CD in jenkins, if due to some error my pipeline fails, it results in a lock in my state file.在 jenkins 中以自动化方式运行 terraform 即 CI/CD 时,如果由于某些错误我的管道失败,它会导致我的状态文件被锁定。 The process to unlock the state file is:解锁状态文件的过程是:

terraform force-unlock id

This works for me, only if I include this command in my jenkinsfile.这对我有用,只有当我在我的 jenkinsfile 中包含这个命令时。 This command does not run in cloud shell and gives the error:此命令未在 Cloud Shell 中运行并给出错误:

Local state cannot be unlocked by another process

As in azure we have an option to remove the lock through Portal via break lease, Do we have any option in GCP?在 azure 中,我们可以选择通过中断租约通过 Portal 解除锁定,我们在 GCP 中有任何选择吗?

Details:细节:

Terraform v0.15 provider GCP v3.63.0 Backend: GCP storage bucket Terraform v0.15 提供商 GCP v3.63.0 后端:GCP 存储桶

Is deleting the default.tflock file the right way?删除 default.tflock 文件的方式是否正确?

I just faced the same problem and well I can't say if that's the good way or not but it worked.我刚刚遇到了同样的问题,我不能说这是否是好方法,但它确实有效。

I've cancelled my Gitlab Pipeline during apply so the lock kept in place without being able to unlock it.我在应用期间取消了我的 Gitlab 管道,因此锁保持在原位而无法解锁。 Removing it did the trick删除它就可以了

I have just renamed lock file name in storage bucket,it has worked我刚刚在存储桶中重命名了锁定文件名,它有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM