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

Ability to cancel a plan/apply using atlantis cancel #187

Open
lkysow opened this issue Jul 17, 2018 · 17 comments
Open

Ability to cancel a plan/apply using atlantis cancel #187

lkysow opened this issue Jul 17, 2018 · 17 comments
Labels
feature New functionality/enhancement help wanted Good feature for contributors

Comments

@lkysow
Copy link
Member

lkysow commented Jul 17, 2018

This feature would enable users to SIGKILL a running apply. This could be added to the apply output page described in #185 or via a comment.

@majormoses
Copy link
Contributor

Ya this is crucial to be able to stop something (such as destroying resources) if an issue was not caught during the plan/review phase.

@bljordan
Copy link

bljordan commented Dec 3, 2018

On a similar note, it'd be nice to be able to cancel a running plan. For example, sometimes the automatic plan of a large amount of resources kicks off, but we really want to do a plan with a -target flag.

@majormoses
Copy link
Contributor

@bljordan #305 is also related to what your asking for.

@lkysow lkysow added the feature New functionality/enhancement label Apr 4, 2019
@smiller171
Copy link

What would happen today if I clicked "discard plan & unlock" in the web UI while running an apply job?

@lkysow
Copy link
Member Author

lkysow commented May 31, 2019

What would happen today if I clicked "discard plan & unlock" in the web UI while running an apply job?

I'm not 100% sure but I know it wouldn't kill the running tf process. It should fail because there's locks on the directories when they're in use but I haven't tested it.

@tomasbackman
Copy link

What would happen today if I clicked "discard plan & unlock" in the web UI while running an apply job?

I'm not 100% sure but I know it wouldn't kill the running tf process. It should fail because there's locks on the directories when they're in use but I haven't tested it.

I just did that.. and it seems like the "unlock" works and the plan is discarded.
But it is not possible to run a new plan due to "workspace currently locked" (by the apply I assume)

@jurgen-weber-deltatre
Copy link

yeah, I would not want this. This is dirty, if you come up with something I think a top level config option to decide if it available or not to users is in order.

@chenrui333 chenrui333 added the help wanted Good feature for contributors label Dec 30, 2021
@leonK-DI
Copy link

I think this feature would be awesome... having same issue here

jamengual pushed a commit that referenced this issue Nov 23, 2022
* sqs

* mark false

* remove unneeded import

* first pass comments

* remove header

* no-op

* move interface
@entscheidungsproblem
Copy link

I think this would be a great feature to have! In particular, I was thinking it would be useful to have an option to stop the execution of atlantis apply if any project in an execution group failed.

So, for example, if I had 2 execution groups, each with 2 projects:

  • group1 with project1a and project1b
  • group2 with project2a and project2b

If project1a or project1b fails on atlantis apply, do not start the execution of the next group, group2.

@nitrocode
Copy link
Member

@entscheidungsproblem (and anyone else interested)

Please feel free to propose a PR to address this feature request.

@ValeriiVozniuk
Copy link

Still needed feature. Simple use case: you see that apply is hang due to some missing dependency, and just waiting to be timed out. You can abort it, fix the dependency, and restart the process. Currently you need to wait for 20-30-40 minutes for apply to fail when timeouts would be reached.

@nitrocode
Copy link
Member

@ValeriiVozniuk thank you for your comment. Please propose a pr and we'd be happy to review it

@entscheidungsproblem
Copy link

entscheidungsproblem commented Jan 20, 2023

@nitrocode I might be able to find some time for a PR but would likely need help with reviewing and testing.

I think this function would need an update

func runProjectCmdsParallelGroups(
cmds []command.ProjectContext,
runnerFunc prjCmdRunnerFunc,
poolSize int,
) command.Result {
var results []command.ProjectResult
groups := splitByExecutionOrderGroup(cmds)
for _, group := range groups {
res := runProjectCmdsParallel(group, runnerFunc, poolSize)
results = append(results, res.ProjectResults...)
}
return command.Result{ProjectResults: results}
}

so the for loop looks like this:

	for _, group := range groups {
		res := runProjectCmdsParallel(group, runnerFunc, poolSize)
		results = append(results, res.ProjectResults...)
+		if res.HasErrors() {
+			break
+		}
	}

But a input flag should also be added to enable/disable this feature

@nitrocode
Copy link
Member

nitrocode commented Feb 5, 2023

That looks promising. Please fork the repo, commit that change to the head branch. Your fork will create a new ghcr image with a dev tag that can then be used as your atlantis. Then you can test this out with your setup and see if your change to catch errors, has the intended effect

Separately but related to this issue, it would be nice to cancel a plan or apply by commenting atlantis cancel or by hitting the api endpoint /api/cancel.

To do that, each time a plan/apply/import/state-rm workflow runs, we would have to save the pid for the job id. Then the cancel command could retrieve the running job id for the pr, get the pid, and then perform a kill on the process, wait until the job is complete, and then finish.

Once we can achieve that, we could also find a way to show running plans/applies in the UI with a cancel button to kill the job gracefully.

@nitrocode nitrocode changed the title Ability to cancel an apply Ability to cancel a plan/apply using atlantis cancel Feb 5, 2023
@neilscallywag
Copy link
Contributor

Any current workarounds for this ?

@jamengual
Copy link
Contributor

jamengual commented May 9, 2024 via email

@ishan123456789
Copy link

ishan123456789 commented Sep 5, 2024

Any current workarounds for this?

Raise another PR from master on no change branch and it should allow to revert the apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement help wanted Good feature for contributors
Projects
None yet
Development

No branches or pull requests