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

atmos terraform force-unlock does not work #800

Open
mss opened this issue Nov 22, 2024 · 6 comments
Open

atmos terraform force-unlock does not work #800

mss opened this issue Nov 22, 2024 · 6 comments
Assignees
Labels
bug 🐛 An issue with the system Short List

Comments

@mss
Copy link
Contributor

mss commented Nov 22, 2024

Describe the Bug

atmos terraform force-unlock worked before but probably only randomly and doesn't work at all anymore (I guess) since v1.100 which now always cleans the workspace. See below for an example.

I guess the proper solution would be to skip the workspace switch for force-unlock.

Expected Behavior

atmos terraform force-unlock should work.

Steps to Reproduce

  1. Configure an S3 backend with a DynamoDB database for locking.
  2. Start some atmos terraform $component --stack $stack apply but cancel it right in the middle by hitting via Ctrl+C twice.
  3. Try atmos terraform plan $component --stack $stack
  4. Try atmos terraform force-unlock $component --stack $stack $uuid where uuid is the value from the previous error.

Screenshots

# atmos terraform force-unlock wms-base --stack wms-xe02-sandbox 8ac7bbfc-c1b4-615d-38d7-f7ba634aa4bb --skip-init

Workspace "wms-xe02-sandbox-wms-base" doesn't exist.

You can create this workspace with the "new" subcommand 
or include the "-or-create" flag with the "select" subcommand.
failed to lock s3 state: operation error DynamoDB: PutItem, https response error StatusCode: 400, RequestID: GK00L3DNLAJF2N4KSMUCPHAMA3VV4KQNSO5AEMVJF66Q9ASUAAJG, ConditionalCheckFailedException: The conditional request failed
Lock Info:
  ID:        8ac7bbfc-c1b4-615d-38d7-f7ba634aa4bb
  Path:      sl-atmos-tfstate-123456789012/wms/xe02/sandbox/wms-xe02-sandbox-wms-base/terraform.tfstate
  Operation: OperationTypeApply
  Who:       stretz@slpn-nb-mss
  Version:   1.8.5
  Created:   2024-11-22 13:59:40.20546289 +0000 UTC
  Info:      

exit status 1

Environment

  • Version 1.105.0

Additional Context

No response

@mss mss added the bug 🐛 An issue with the system label Nov 22, 2024
@aknysh
Copy link
Member

aknysh commented Nov 22, 2024

@mss thank you for reporting this

@mss
Copy link
Contributor Author

mss commented Nov 25, 2024

Just using the default workspace (via TF_WORKSPACE=default) doesn't work, results in the error Failed to unlock state: failed to retrieve lock info for lock ID "8ac7bbfc-c1b4-615d-38d7-f7ba634aa4bb": unexpected end of JSON input. From running the whole thing with TF_LOG=debug it looks like the LockID is wrong.

@mss
Copy link
Contributor Author

mss commented Nov 25, 2024

This doesn't work either:

TF_WORKSPACE=default atmos terraform shell wms-base --stack wms-xe02-sandbox
unset TF_WORKSPACE
terraform workspace new -lock=false wms-xe02-sandbox-wms-base
terraform force-unlock 8ac7bbfc-c1b4-615d-38d7-f7ba634aa4bb

The terraform workspace new fails already. Looks like the -lock=false is ignored so there may be a terraform bug involved as well?

@GabisCampana
Copy link

Hi @mss
We are tracking this bug and will look into it. Can not promise an ETA though

@mss
Copy link
Contributor Author

mss commented Nov 26, 2024

I think this is at least partially broken on the Terraform side, cf. linked ticket.

@GabisCampana
Copy link

@aknysh FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system Short List
Projects
Status: Todo
Development

No branches or pull requests

4 participants