-
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 apply all after a failed apply; outputs Ran Apply for 0 projects #773
Comments
Yeah it's a bug. If autoplan had been enabled then there would have been new plans generated and the apply wouldn't have worked. |
@lkysow Thanks for the confirmation. This bug is killing us right now. We want people to be able see non-locking plans being run (in our normal CI pipleine) before Approvals are submitted so they can actually validate their code before blocking other development. If we wanted to dig into solving this, where would be a good place to start looking? I took a really quick glance through the repo and nothing jumped out at me. Thank you for building this tool by the way, I really appreciate the work that went into this. |
After re-reading the ticket, this isn't technically a bug (although for your use-case it may as well be). Atlantis is just doing what you told it, it's up to you to run Also if you were running with the If we were to add some functionality to detect this case, it would be here: https://github.com/runatlantis/atlantis/blob/master/server/events/project_command_builder.go#L204 after Atlantis has found no pending plans. It could then exit with an error in this case. I think a path forward may be:
|
Well, I actually think your original interpretation made sense to me. To clarify, we would never want atlantis to apply without having the most up to date plan saved and locked. What we’re doing instead is just running validate, fmt, lint and I still think this is a bug. Yes I wanted autoplan disabled but that just means I want the developers to run it if and only if all the pre-apply requirements are met. I would expect the apply step to run the same validation that the plan is locked and up to date and apply based on that. Turning off autoplan shouldn’t affect those checks. What seems to be happening with autoplan disabled is the apply is ignoring the plans and ultimately just applies nothing. I can confirm there are plans and locks are created when they are supposed to be. It appears that the atlantis apply step is just ignoring those if a second apply is run after this first one fails. Expected behavior would be for the apply step to either force a replan if the MR was updated, or attempt to re-apply the original plan. It’s doing neither of these right now. |
One thing I did notice was that if the apply does fail, the saved plans are deleted but the locks are left open (this may be the actual bug here). If we removed those after a failed apply, that would basically force the plan step. I don’t know if that’s the best solution but I think it would work. |
Our team has autoplan on, but pushing a new commit doesn't cause Atlantis to redo the plan (because Bitbucket).
I agree we should either have Atlantis not delete the plans, or error if an apply is attempted without any plans. @lkysow - what's the reason for Atlantis to delete the plans after a failed apply? It could have failed because a transient provider issue, and re-running apply on the same plan would later succeed. |
HI everyone I met this issue too. |
Running plan on the same PR after a failed to apply should not be any different than if atlantis does not delete the plan, it is just an extra step. But if someone else in another PR modify the environment you are running plan against you will have a problem no matter what but by re-running a plan you could actually find the drift. I do not think this is a bug, it is a bit annoying to run plan again but since terraform is idempotent it should only apply the difference. |
I can run If I run with |
with autoplan, you need to define every directory you want autoplan on/off in your atlantis.yaml otherwise it does not work, is what you guys are doing? if this was a bug, no one will be using atlantis so I want to make sure if this is specific to multi-dir structure etc. For that, we need to see the altlantis.yaml files and dir structure so we can have a better idea. This could be as simple as better documentation of autoplan with some examples. |
@jamengual I am using an I discovered that if i run I have autoplan on, but if I run Also of note, I am using custom workflows, not sure if that makes a difference. |
@evanstachowiak Please test with the pre-release image, we did some bug fixes there and I wonder if that could be the issue:
|
is this still an issue with |
Hello @jamengual I was able to reproduce this issue on It only happened when using pre workflow hooks, such as the following: ---
repos:
- id: /.*/
pre_workflow_hooks:
- run: echo "hello world" The server logs for the execution:
|
yes it's still an issue @jamengual |
I wonder if this is related to this : #1633 |
pre_workflow_hooks run before any atlantis.yaml file is parsed. after that if no atlantis.yaml is defined it it will do nothing. |
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.' |
@jamengual Hello! Recently I reproduced that problem on |
can you describe the steps you took to reproduce it? |
Sure! Repos config:
atlantis.yaml example:
As a result, I have an MR message:
|
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.' |
I also face this issue on v0.28.1. I have a multi-dir structure (mono-repository) with a lot of projects (> 300). I recently introduced a CI stage that has to run before Atlantis. Because there's no other way of pipelining this (running the CI stage before Atlantis), I disabled the autoplan feature from atlantis.yaml everywhere and added a step in our pipeline that comments The issue occurred after Atlantis successfully generated the plans, then the PR was rebased and until Atlantis finished planning, another user commented Is there any chance this issue will be reopened? LE: I found a workaround for now, at least for our use-case: I added a pre-workflow-hook with |
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.' |
is there any permanent solution for this? |
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.' |
Did anyone figure out a workaround for this issue? |
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.' |
I have a repo that uses the default workspace but there are a number of different project folders.
Atlantis version: 0.8.3
Terraform version: v0.12.8
Plans are generated for all three projects as normal after commenting exactly
atlantis plan
.Immediately afterword, commenting
atlantis apply
attempts to apply all three environments as expected. In this case, there was an apply error due to an AWS IAM policy being misconfigured and the plans were not successfully applied. A commit was pushed to fix this issue and anotheratlantis apply
was submitted. Note, there was not anotheratlantis plan
after the fix commit was pushed. Atlantis behaved as if it had forgotten about the failed plans and assumed they had been applied successfully when, in fact, they had not been. I believe the expected behavior should be to reject the apply since new commits were made and force another plan be run, correct?The result was the following:
The text was updated successfully, but these errors were encountered: