-
Notifications
You must be signed in to change notification settings - Fork 48
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
feature request: apply on merge #162
Comments
piling on my own request, plan on push would be dandy as well :) |
Thanks for the ticket! The main reason we do apply on comment is that often there are errors when you run That being said, I don't think there's a reason we couldn't also support a final apply on merge for any plans that are outstanding. What do you think @anubhavmishra? For plan on push, we definitely agree this is needed. I created #165 to track this separately. |
Hi @lkysow ... hrm, you're right, there are often errors when you apply. Can a closed PR still be updated by Atlantis? That final run should still be pushed back to the PR I think so there is some record of it. I guess for us, there are some projects that are trivial, or some changes that are trivial and unlikely to fail, and it'd be nice to "one-step" it. Maybe make it configurable per-project in the atlantis.yaml file? We've built a workflow in chef and kubernetes around pushing merge being the act of actually deploying the work, maybe that doen't fit for terraform. |
I love that workflow and I think it totally fits for terraform. We just need to figure out the workflow if an Here's what we could do:
Questions I have:
@anubhavmishra thoughts? |
FWIW seems sane to me. We're already used to "Merge pull request" being 'dangerous' on some repos (ie: your work will go live right now). If you really want to get ambitious, you could fire a webhook at a user configurable URL in addition to GH so I could intercept and publish updates to Cisco Spark (our collaborative chat tool) -- but that's becoming feature creep |
As an operator I like the idea of planning for a environment and applying that to the environment and then seeing a result back in the same place. But I like the idea of apply on merge to master. If you have planned for multiple environments in the PR we will need to figure out a way to track each one of things that needs to applied and handle errors after the fact. |
Well it depends, if you force push (after squashing,rebasing, etc) no you will need a new PR. |
I like the concept of apply on merge but I don't think it is practical because bugs exist in code and are often break on the simplist of things (like adding a new key to an array in json and not putting the comma). I think you should apply it and if it succeeds you merge it, until it succeeds it should stay in a feature branch imho. I realize that as I also follow the mantra of master is the source of truth and deployable anywhere is guiding me here. The nature of terraform sorta conflicts with this mantra to a certain extent but is less of a concern if you use remote state files. |
How would you deal with multiple PRs merged at the same time? |
@grobie atlantis will "lock" a directory and workspace to prevent other plans from other PR's when there's an unapplied plan pending so you wouldn't have the issue of two PR's attempting to be planned. You are correct that there's still an issue however. If there's a pending plan (in say PR 10) and I open up another pull request (say PR 11), then we won't be able to autoplan in 11. If 10 gets merged, then the user would have to comment on the pull request to get the plan to appear. I'm thinking about using the following config in ...
pipelines:
...
apply:
on_merge: true # will apply any unapplied plans on merge |
The lock wouldn't prevent some overzealous engineer to merge their PR, right? I'm currently playing around with Github's merge protection features etc. to figure out how to set up enough safe guards to prevent that (might be useful to document that in Atlantis somehwere). |
Correct. We could have the |
One problem here is that the status checks run one time unless there is some change such as a comment or commit triggers it to run again. This is not a reliable mechanism to check lock status. There will always be race conditions. |
Would be great if merging a PR triggered a
terraform apply
The text was updated successfully, but these errors were encountered: