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

The default workspace at path terraform/sandbox/atlantis is currently locked by another command that is running for this pull request. #4302

Closed
genfemme opened this issue Mar 1, 2024 · 39 comments
Labels
bug Something isn't working

Comments

@genfemme
Copy link

genfemme commented Mar 1, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

"I am experiencing a persistent issue where Atlantis reports that the default workspace is locked due to another command. Despite using atlantis unlock, the issue persists, preventing any new plans or applies."

Reproduction Steps

Execute atlantis plan in a pull request.
Encounter a workspace lock error.
Attempt to unlock using atlantis unlock.
Re-run atlantis plan and face the same lock error.

Error details

`Ran Plan for dir: terraform/sandbox/atlantis workspace: default

Plan Error

The default workspace at path terraform/sandbox/atlantis is currently locked by another command that is running for this pull request.
Wait until the previous command is complete and try again.`

Logs

[DBUG] 5 files were modified in this pull request
[DBUG] got workspace lock
[DBUG] clone directory "/home/atlantis/.atlantis/repos/Projects/terraform-sandbox/11/default" already exists, checking if it's at the right commit
[DBUG] repo is at correct commit "a053e755a69ca20ca902397974d5eaf66cb1b2f1" so will not re-clone
[INFO] successfully parsed atlantis.yaml file
[DBUG] moduleInfo for /home/atlantis/.atlantis/repos/Projects/terraform-sandbox/11/default (matching "") = map[]
[DBUG] found downstream projects for "atlantis.yaml": []
[DBUG] found downstream projects for "terraform/_env/atlantis.hcl": []
[DBUG] found downstream projects for "terraform/sandbox/atlantis/terragrunt.hcl": []
[DBUG] found downstream projects for "terraform/sandbox/atlantis_wrapper/main.tf": []
[DBUG] found downstream projects for "terraform/sandbox/atlantis_wrapper/server-atlantis.yaml": []
[DBUG] checking if project at dir "terraform/sandbox/base" workspace "default" was modified
[DBUG] checking if project at dir "terraform/sandbox/application" workspace "default" was modified
[DBUG] checking if project at dir "terraform/sandbox/cluster" workspace "default" was modified
[DBUG] checking if project at dir "terraform/sandbox/atlantis" workspace "default" was modified
[DBUG] file "terraform/sandbox/atlantis/terragrunt.hcl" matched pattern
[INFO] 1 projects are to be planned based on their when_modified config
[DBUG] determining config for project at dir: "terraform/sandbox/atlantis" workspace: "default"
[DBUG] MergeProjectCfg started
[DBUG] setting apply_requirements: [approved] from repos[1], id: /.*/
[DBUG] setting import_requirements: [] from default server config
[DBUG] setting workflow: "default" from repos[1], id: /.*/
[DBUG] setting allowed_overrides: [apply_requirements,workflow] from repos[1], id: /.*/
[DBUG] setting allow_custom_workflows: true from repos[1], id: /.*/
[DBUG] setting delete_source_branch_on_merge: false from default server config
[DBUG] setting repo_locking: true from default server config
[DBUG] setting plan_requirements: [] from default server config
[DBUG] MergeProjectCfg completed
[DBUG] overriding server-defined workflow with repo-specified workflow: "terragrunt"
[DBUG] MergeProjectCfg completed
[DBUG] final settings: plan_requirements: [], apply_requirements: [approved], import_requirements: [], workflow: terragrunt
[DBUG] Building project command context for plan
[INFO] Cannot determine which version to use from terraform configuration, detected 0 possibilities.
[DBUG] deleting previous plans and locks
[INFO] acquired lock with id "Projects/terraform-sandbox/terraform/sandbox/atlantis/default"
[DBUG] acquired lock for project
[EROR] Error running plan operation: The default workspace at path terraform/sandbox/atlantis is currently locked by another command that is running for this pull request.
Wait until the previous command is complete and try again.
@genfemme genfemme added the bug Something isn't working label Mar 1, 2024
@genfemme
Copy link
Author

genfemme commented Mar 2, 2024

Waiting for response

@jamengual
Copy link
Contributor

atlantis, version? VCS? atlantis.yaml, repo config? we need to see how you configured it

@jamengual
Copy link
Contributor

jamengual commented Mar 3, 2024 via email

@genfemme
Copy link
Author

genfemme commented Mar 4, 2024

@jamengual

atlantis:v0.24.2

This is the atlantis.yaml file -

version: 3
projects:
- name: base
  dir: terraform/sandbox/base
  terraform_version: v1.6.6
  workflow: terragrunt
  workspace: base
  autoplan:
    enabled: true
  apply_requirements: [approved]
- name: application
  dir: terraform/sandbox/application
  terraform_version: v1.6.6
  workflow: terragrunt
  workspace: application
  autoplan:
    enabled: true
  apply_requirements: [approved]
- name: cluster
  dir: terraform/sandbox/cluster
  terraform_version: v1.6.6
  workflow: terragrunt
  workspace: cluster
  autoplanP:
    enabled: true
  apply_requirements: [approved]
- name: atlantis
  dir: terraform/sandbox/atlantis
  terraform_version: v1.6.6
  workflow: terragrunt
  workspace: atlantis
  autoplan:
    enabled: true
  apply_requirements: [approved]

workflows:
  terragrunt:
    plan:
      steps:
      - run: terragrunt plan -no-color -input=false -out=$PLANFILE
    #apply:
    #  steps:
    #  - run: terragrunt apply -no-color -input=false $PLANFILE

This is the repo.config
repos:

  • id: /.*/
    allow_custom_workflows: true
    allowed_overrides:

    • apply_requirements
    • workflow
      apply_requirements:
    • approved

    Is repo.config required? I have tried without this as well but still the same issue.

@genfemme
Copy link
Author

genfemme commented Mar 4, 2024

waiting for response

@jamengual
Copy link
Contributor

have you tried to update atlantis?

@genfemme
Copy link
Author

genfemme commented Mar 4, 2024

What version are you suggesting?

@jamengual
Copy link
Contributor

latest, 0.27.1

@genfemme
Copy link
Author

genfemme commented Mar 4, 2024

Are there any breaking changes in Atlantis v0.27.1 that would require modifications to our existing atlantis.yaml or repository configuration files?

@jamengual
Copy link
Contributor

jamengual commented Mar 4, 2024 via email

@genfemme
Copy link
Author

I updated the image to Atlantis v0.27.1 but still getting the same error.
Following are the details -

the sandbox workspace at path terraform/sandbox is currently locked by another command that is running for this pull request. Wait until the previous command is complete and try again

[DBUG] Building plan command for all affected projects [DBUG] 3 files were modified in this pull request. Modified files: [atlantis.yaml server-atlantis.yaml terraform/_env/base.hcl] [DBUG] got workspace lock [INFO] successfully parsed atlantis.yaml file [DBUG] moduleInfo for /home/atlantis/.atlantis/repos/AdharaProjects/terraform-sandbox/14/default (matching "") = map[] [DBUG] found downstream projects for "atlantis.yaml": [] [DBUG] found downstream projects for "server-atlantis.yaml": [] [DBUG] found downstream projects for "terraform/_env/base.hcl": [] [DBUG] checking if project at dir "terraform/sandbox" workspace "sandbox" was modified [DBUG] file "terraform/_env/base.hcl" matched pattern [INFO] 1 projects are to be planned based on their when_modified config [DBUG] determining config for project at dir: "terraform/sandbox" workspace: "sandbox" [DBUG] MergeProjectCfg started [DBUG] setting repo_locking: true from default server config [DBUG] setting policy_check: false from default server config [DBUG] setting plan_requirements: [] from default server config [DBUG] setting workflow: "default" from repos[1], id: /.*/ [DBUG] setting delete_source_branch_on_merge: false from default server config [DBUG] setting allow_custom_workflows: true from repos[1], id: /.*/ [DBUG] setting custom_policy_check: false from default server config [DBUG] setting apply_requirements: [approved] from repos[1], id: /.*/ [DBUG] setting import_requirements: [] from default server config [DBUG] setting allowed_overrides: [apply_requirements,workflow] from repos[1], id: /.*/ [DBUG] MergeProjectCfg completed [DBUG] overriding server-defined workflow with repo-specified workflow: "terragrunt" [DBUG] MergeProjectCfg completed [DBUG] final settings: plan_requirements: [], apply_requirements: [approved], import_requirements: [], workflow: terragrunt [DBUG] Building project command context for plan [DBUG] deleting previous plans and locks [INFO] acquired lock with id "AdharaProjects/terraform-sandbox/terraform/sandbox/sandbox" [DBUG] acquired lock for project [EROR] Error running plan operation: the sandbox workspace at path terraform/sandbox is currently locked by another command that is running for this pull request. Wait until the previous command is complete and try again

Please can you suggest on how to proceed with this?

@jamengual
Copy link
Contributor

jamengual commented Mar 13, 2024 via email

@genfemme
Copy link
Author

This is the first deployment in this repo. This is the only repo that has atlantis deployed.
This is the error that I get when waiting for the autoplan to run.

I have also tried to unlock via the URL manually and by running atlantis unlock in the github PR and the issue remans the same.

I haven't set any parallel plans and to avoid this. I amended the file as per below -

`version: 3
projects:

  • name: base
    dir: ./terraform/sandbox
    terraform_version: v1.6.6
    workflow: terragrunt
    workspace: sandbox
    autoplan:
    when_modified:
    • "../_env/base.hcl"
      enabled: true

workflows:
terragrunt:
plan:
steps:
- run: terragrunt init -input=false -no-color && terragrunt run-all plan -no-color -input=false -out=$PLANFILE`

And this is the server side config again -
{ "name": "ATLANTIS_REPO_CONFIG_JSON", "value": "{\"repos\":[{\"id\":\"/.*/\",\"apply_requirements\":[\"approved\"],\"allowed_overrides\":[\"workflow\"]}]}" }

I also added this in the repo - server-atlantis.yaml
`repos:

  • id: /.*/
    apply_requirements:
    • approved
      allowed_overrides:
    • workflow `

@jamengual
Copy link
Contributor

so the unlock command was changed recently and a fix was pushed to 0.27.2 so if you run unlock it will actually clear the workspace and any locks.

and you could disable https://www.runatlantis.io/docs/server-configuration.html#parallel-plan

@genfemme
Copy link
Author

genfemme commented Mar 13, 2024

It does clear the locks as per this comment that I receive in this PR -
All Atlantis locks for this PR have been unlocked and plans discarded

Also the URL doesn't show any locks.

But when I run the plan again manually by adding altantis plan or via a new PR I get the same error.

Are you suggesting to update the version to this now -0.27.2 to fix the issue?

@jamengual
Copy link
Contributor

jamengual commented Mar 13, 2024 via email

@genfemme
Copy link
Author

Ok thanks I will update the image version and will add an update here after it is done.

@genfemme
Copy link
Author

Still getting the error with 0.27.2 -

`the sandbox workspace at path terraform/sandbox is currently locked by another command that is running for this pull request.
Wait until the previous command is complete and try again

[DBUG] Building plan command for all affected projects [DBUG] 3 files were modified in this pull request. Modified files: [atlantis.yaml server-atlantis.yaml terraform/_env/base.hcl] [DBUG] got workspace lock [INFO] successfully parsed atlantis.yaml file [DBUG] moduleInfo for /home/atlantis/.atlantis/repos/AdharaProjects/terraform-sandbox/16/default (matching "") = map[] [DBUG] found downstream projects for "atlantis.yaml": [] [DBUG] found downstream projects for "server-atlantis.yaml": [] [DBUG] found downstream projects for "terraform/_env/base.hcl": [] [DBUG] checking if project at dir "terraform/sandbox" workspace "sandbox" was modified [DBUG] file "terraform/_env/base.hcl" matched pattern [INFO] 1 projects are to be planned based on their when_modified config [DBUG] determining config for project at dir: "terraform/sandbox" workspace: "sandbox" [DBUG] MergeProjectCfg started [DBUG] setting repo_locking: true from default server config [DBUG] setting policy_check: false from default server config [DBUG] setting plan_requirements: [] from default server config [DBUG] setting import_requirements: [] from default server config [DBUG] setting workflow: "default" from repos[1], id: /.*/ [DBUG] setting allowed_overrides: [apply_requirements,workflow] from repos[1], id: /.*/ [DBUG] setting apply_requirements: [approved] from repos[1], id: /.*/ [DBUG] setting allow_custom_workflows: true from repos[1], id: /.*/ [DBUG] setting delete_source_branch_on_merge: false from default server config [DBUG] setting custom_policy_check: false from default server config [DBUG] MergeProjectCfg completed [DBUG] overriding server-defined workflow with repo-specified workflow: "terragrunt" [DBUG] MergeProjectCfg completed [DBUG] final settings: plan_requirements: [], apply_requirements: [approved], import_requirements: [], workflow: terragrunt [DBUG] Building project command context for plan [DBUG] deleting previous plans and locks [INFO] acquired lock with id "AdharaProjects/terraform-sandbox/terraform/sandbox/sandbox" [DBUG] acquired lock for project [EROR] Error running plan operation: the sandbox workspace at path terraform/sandbox is currently locked by another command that is running for this pull request. Wait until the previous command is complete and try again

@jamengual
Copy link
Contributor

jamengual commented Mar 13, 2024 via email

@genfemme
Copy link
Author

Autoplan just hangs.

The logs are when I run it manually using the below command in the github PR
atlantis plan --verbose

@genfemme
Copy link
Author

after doing the atlantis unlock

@genfemme
Copy link
Author

Do you have any more suggestions please to resolve the issue?

@jamengual
Copy link
Contributor

jamengual commented Mar 14, 2024 via email

@genfemme
Copy link
Author

Did anyone mentioned the similar issue in the slack channel?
I have tried without the autoplan and still getting the same issue.

@genfemme
Copy link
Author

waiting for response

@genfemme
Copy link
Author

genfemme commented Apr 2, 2024

anyone?

@jamengual
Copy link
Contributor

did you closed the PR and reopen again? when you do that Atlantis will clear the PR clone
There is no reason to get that error if you have only 1 PR

@genfemme
Copy link
Author

genfemme commented Apr 3, 2024

Yes I have closed and reopen PR couple of times already. Closing the PR does clears the clone. When I run the atlantis plan again I get the same error

@jamengual
Copy link
Contributor

jamengual commented Apr 3, 2024 via email

@jamengual
Copy link
Contributor

jamengual commented Apr 3, 2024 via email

@genfemme
Copy link
Author

genfemme commented Apr 3, 2024

I changed the file with the details here - #4302 (comment)

@genfemme
Copy link
Author

genfemme commented Apr 7, 2024

are you running from docker? I'm wondering if you have bad permissions on the Atlantis-data dir, have you wiped the install and started again ?

On Wed, Apr 3, 2024, 2:25 a.m. genfemme @.> wrote: Yes I have closed and reopen PR couple of times already. Closing the PR does clears the clone. When I run the atlantis plan again I get the same error — Reply to this email directly, view it on GitHub <#4302 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ3ERF2AUI46SMM3YB6CBDY3PDJJAVCNFSM6AAAAABEBRHTZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZUGAZDQNZUGQ . You are receiving this because you were mentioned.Message ID: @.>

Yes I have

@dbg-raghulkrishna
Copy link

I am also experiencing this when i switched from github user authentication to github application auth

@jamengual
Copy link
Contributor

jamengual commented Apr 16, 2024 via email

@dbg-raghulkrishna
Copy link

yes it did not happen before , from last week it is happening after switching to githun app, it is even happening for the changes in the folder that's not included in the projects

@dbg-raghulkrishna
Copy link

example log
This happens only with github app authentication
Error running pre-workflow hooks the default workspace at path . is currently locked by another command that is running for this pull request.\nWait until the previous command is complete and try again.","json":{"repo":"","pull":""},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgh.neting.cc/runatlantis/atlantis/server/events/command_runner.go:340"}

@jamengual
Copy link
Contributor

jamengual commented Apr 17, 2024 via email

@jamengual
Copy link
Contributor

@lukemassa do you have any ideas of what else it could be?

@jamengual
Copy link
Contributor

I will close this since I think we exhausted many of the possible issues.
If you think this is still an issue please post in in slack to see if other people can give you some clues of what to do but if this was an atlantis issue we will have plenty of issues and slack messages about this and we do not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants