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

Locked by another command is not visible as pending #1847

Open
n0rad opened this issue Oct 8, 2021 · 8 comments
Open

Locked by another command is not visible as pending #1847

n0rad opened this issue Oct 8, 2021 · 8 comments
Labels
bug Something isn't working never-stale Stale waiting-on-response Waiting for a response from the user

Comments

@n0rad
Copy link

n0rad commented Oct 8, 2021

Hello,

While using github, when a plan is in progress and another plan is triggered, manually or especially by a new commit when iterating on the PR, Atlantis send the following comment :

The default workspace is currently locked by another command that is running for this pull request.
Wait until the previous command is complete and try again.

and set the check status as failed.

it's disturbing because the user cannot be sure that something is really still in progress, depending on when he is browsing the PR.
I think Atlantis should set the check as pending, so it's clearly visible that the user should wait.

@n0rad n0rad added the bug Something isn't working label Oct 8, 2021
@jamengual
Copy link
Contributor

is this still happening with v0.19.8?

@jamengual jamengual added the waiting-on-response Waiting for a response from the user label Aug 26, 2022
@n0rad
Copy link
Author

n0rad commented Sep 28, 2022

just tested on 0.19.7 and it's still the case. I will check on 0.19.8 when possible.

@jhaumont
Copy link

I face the same issue today ! Any update?

@github-actions github-actions bot added the Stale label Oct 30, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2022
@jamengual jamengual reopened this Dec 1, 2022
@github-actions github-actions bot removed the Stale label Dec 2, 2022
@github-actions
Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.'

@github-actions github-actions bot added the Stale label Mar 14, 2023
@DavidPessoa
Copy link

I have this issue on 0.22.3
The default workspace at path .... is currently locked by another command that is running for this pull request.
Wait until the previous command is complete and try again.

With parallel plan/apply disabled

@nitrocode nitrocode removed the Stale label Mar 29, 2023
@github-actions
Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.'

@github-actions github-actions bot added the Stale label Apr 30, 2023
@nitrocode
Copy link
Member

The message comes from TryLock function

func (d *DefaultWorkingDirLocker) TryLock(repoFullName string, pullNum int, workspace string, path string) (func(), error) {
d.mutex.Lock()
defer d.mutex.Unlock()
pullKey := d.pullKey(repoFullName, pullNum)
workspaceKey := d.workspaceKey(repoFullName, pullNum, workspace, path)
for _, l := range d.locks {
if l == pullKey || l == workspaceKey {
return func() {}, fmt.Errorf("The %s workspace at path %s is currently locked by another"+
" command that is running for this pull request.\n"+
"Wait until the previous command is complete and try again.", workspace, path)
}
}
d.locks = append(d.locks, workspaceKey)
return func() {
d.unlock(repoFullName, pullNum, workspace, path)
}, nil
}

Here are all the references to that function

https://github.com/search?q=repo%3Arunatlantis%2Fatlantis+TryLock&type=code

I'd imagine it all starts at the pre workflow run's RunPreHooks function

unlockFn, err := w.WorkingDirLocker.TryLock(baseRepo.FullName, pull.Num, DefaultWorkspace, DefaultRepoRelDir)
if err != nil {
return err
}
log.Debug("got workspace lock")
defer unlockFn()

Which is then called from these locations... But from looking at these, it seems it catches the error, skips over them, and runs the command anyway

err = c.PreWorkflowHooksCommandRunner.RunPreHooks(ctx, nil)
if err != nil {
ctx.Log.Err("Error running pre-workflow hooks %s. Proceeding with %s command.", err, command.Plan)
}
autoPlanRunner := buildCommentCommandRunner(c, command.Plan)
autoPlanRunner.Run(ctx, nil)

err = c.PreWorkflowHooksCommandRunner.RunPreHooks(ctx, cmd)
if err != nil {
ctx.Log.Err("Error running pre-workflow hooks %s. Proceeding with %s command.", err, cmd.Name.String())
}
cmdRunner := buildCommentCommandRunner(c, cmd.CommandName())
cmdRunner.Run(ctx, cmd)

More code diving is needed. This is to get someone started.

@github-actions github-actions bot removed the Stale label May 4, 2023
@github-actions
Copy link

github-actions bot commented Jun 4, 2023

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working never-stale Stale waiting-on-response Waiting for a response from the user
Projects
None yet
Development

No branches or pull requests

5 participants