-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Atlantis unlock fails to delete plan of environment with project name #3845
Comments
@X-Guardian do you think you could check if this is the case? |
Yes, the Atlantis locks controller has no knowledge of projects. |
Several tickets have been raised bout this same issue, so here is a clarification of the current situation: The file name of the terraform plan file produced by Atlantis for each project differs depending upon the following conditions:
you can see the code for this here: atlantis/server/core/runtime/runtime.go Lines 89 to 97 in f34e5db
The problem is that the locks controller functions have no knowledge of the project name, so if this is set, the deletion of the plan file will fail in the unlock functions. To fix this would need the locks controller functions plus other higher level functions updating with details of the project including the project name. I expect there are more bugs within the locks controller when multiple projects are specified for the same directory and different project names. Easy workaround for now is if you are not using multiple projects for the same directory within your |
We have multiple
The lock is removed! Not a big deal really, just trying my luck frankly.. |
Unfortunately this workaround does not suit me. Without project name it is really inconvenient since the path is really long and in gh issue summary(CI block check) contains base path that is common for all all projects + Moreover I liked that Atlantis removed the whole workspace during unlock(when I need to free disk space) and for me it would be better to control via option(like -cleanup-worksapce-on-unclock): #3751 Are you planing to fix this? |
The workaround doesn't cover my use case as well. Is there any way to get to the previous behaviour? |
For those who have issues with the way that unlock is working now, I will ask that if you have the time and golang knowledge to fix it, please create a PR for it. We are trying to avoid adding more flags so we could add this to the repo.config if is needed. |
Sure. Shall I create a revert of #3751? |
No |
OK, meanwhile I will have to rollback to 0.25.0 because I have a pileup of PRs that won't unlock that I keep having to unlock manually. |
+1 with this, we use multiple projects in the same directory and its not rmving the plan file, we will need to rollback to 0.25.0 😭 |
If it was a quick fix, it would have been done already. Better to rollback to |
FYI, I do not use the version: 3
projects:
- dir: align/production/align-home
terraform_version: v1.3.8
workflow: terragrunt
autoplan:
enabled: true
when_modified:
- '*.hcl'
- '*.tf'
- atlantis.yaml |
Hello everyone, we will revert #3751. I approved the change and actually was worried about this very issue. We have been working to better understand the differences between locks and filesystem operations. I apologize for the disruptions. The code is spread out across the lock controllers, command controllers, and a special library for file system operation for "WorkingDir". I appreciate everyones patience as we continue to streamline and optimize these operations. It makes more sense to properly support project locks across the codebase before making these changes. |
To clarify, this revert may not result in a "full revert" but there will be at a minimum, a revert in functionality. We are still debating options internally on the core team. Most likely solution is a new PR that will keep both behaviors, gated by a configuration flag. |
these tests you have done have been always on the same PR?
you could try to create another PR and see how it works or close and reopen
your current PR.
if this is a brand-new setup, you should not have this issue.
…On Fri, Mar 15, 2024 at 7:22 AM Dimitris Moraitidis < ***@***.***> wrote:
this issue seems to still be there.
When trying "atlantis unlock", I see: "Failed to delete PR locks"
but lock is properly unlocked:
image.png (view on web)
<https://github.com/runatlantis/atlantis/assets/6890249/df9f6614-1f06-41c1-bbe9-0582f2c38ec0>
My atlantis repo config looks like this:
version: 3
projects:
- name: main
workflow: main
dir: .
autoplan:
when_modified: ["*.tf", "env-vars/main.tfvars"]
workflows:
main:
plan:
steps:
- init:
extra_args: ["-backend-config=backend-configs/main.hcl", "-reconfigure", "-upgrade"]
- plan:
extra_args: ["-var-file=env-vars/main.tfvars"]
apply:
steps:
- apply
—
Reply to this email directly, view it on GitHub
<#3845 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQ3ERC6JFD7M2IP5FEBKLTYYL7YRAVCNFSM6AAAAAA54J56LSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJZG43TIMJQG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@jamengual Indeed, this did not happen in a new PR, ensuring that it was opened after atlantis was upgraded to 0.27.2 Thanks! |
I'm glad to hear is working |
Hi @jamengual :) We just upgraded our Atlantis version to get the fix for this issue and unfortunately it came back after some time, i.e, we tried to run the atlantis unlock on a PR and then we got the Failed to delete PR locks message. Checking our Atlantis logs, we found the following:
Have you seen any error similar to this one since this fix is live? |
I've also noticed this happening, but only on a closed PR |
Thanks for sharing. In our case, the PR had only been opened the day before :/ |
the unlock was run on a project that had a different project/workflow configuration? |
Just upgraded to 0.27.2 from 0.25.0 today and saw the same |
No, in this case it was on the same project. |
There is a fair chance #4502 will fix this (and a couple of other |
#3750 changed the behaviour of
atlantis unlock
which used to trigger a deletion of the whole directory where the PR is checked out in favour of only deleting the plan file.The delete lock command however doesn't handle configuration with project names configured, which causes issues: https://github.com/runatlantis/atlantis/blob/v0.26.0/server/events/delete_lock_command.go#L60
Reproduction Steps
Atlantis version: v0.26.0
Given an atlantis.yaml:
When an
atlantis unlock
is issued:The plan file is actually named
dev-default.tfplan
afterfmt.Sprintf("%s-%s.tfplan", projName, workspace)
.A workaround is to remove project names from the Atlantis config and rely only on dir names.
The text was updated successfully, but these errors were encountered: