-
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
add flag for rebasing branch off master #374
Conversation
Fixes #35 |
Codecov Report
@@ Coverage Diff @@
## master #374 +/- ##
==========================================
- Coverage 70.3% 70.22% -0.09%
==========================================
Files 62 62
Lines 3742 3758 +16
==========================================
+ Hits 2631 2639 +8
- Misses 923 930 +7
- Partials 188 189 +1
Continue to review full report at Codecov.
|
For this flag to work users must set a gitconfig that contains a email address. I was not sure the best way to document this since it's supplied optionally by however the user runs it. |
Would it make more sense to use the This is more in-line with how Travis CI works: https://docs.travis-ci.com/user/pull-requests#how-pull-requests-are-built Note that if the master branch changes then it will be out of date, however with locking, the master branch shouldn't be changing so that might be okay. |
@lkysow using As for the second thing I would certainly prefer to always rebase and not assume that the master branch has not changed. Thoughts? |
It's now being tested and used in a few environments by me to validate it with real use cases. I have a outstanding question if you are relying on the sideffect here or if this is being used to clone |
Looks like those tests are failing because I removed the extra clone. |
So looking at the tests that are failing now they are comment tests and with my recent changes it looks like it expects the repo to exist. So I need to revert my change to make the comment always clone. |
I'm curious if you tried to implement this using a custom workflow? I'm not sure if it makes sense for the atlantis core to have this setting. |
@lkysow What do you mean by custom workflows I'm not familiar. |
Using the custom |
ahh I see using a custom workflow in atlantis. That seems like a viable way to accomplish it. I think my current complaint about the customization is I have to do it for each main.tf which in our case is about 30 as we still don't have a default workflow in atlantis correct? |
I'll go ahead and close this if you prefer it implemented via the custom commands. |
Does it work with custom commands? I haven't tried it. Just wanted to know if it was an option. If it does work, then I think I would prefer that it be implemented that way to keep Atlantis more in-line with how circle-ci works. If it doesn't, I'm not against adding it as an option. This is how travis ci works. However it still has edge cases because master could change between plan and apply phases. With the latest server-side config RFC, you can specify a default workflow on the server: https://docs.google.com/document/d/1w2wePfXGA3L151Af6D0kB1aKVB7pXys_l9Vk9SD7kyA so that will fix the issue of having to write it multiple times. |
@lkysow sounds good I look forward to that RFC being implemented. I'll test it out and get back to you, but I suspect it will work. |
I personally think this should not come from a custom workflow and should be a first class feature in atlantis as its something like realistically most people want and having to have 99% of people setup custom workflows for a generally desired behavior does not seem like the best experience to me. |
I'm not certain that it's something everyone wants. For instance in CircleCI, it runs against the branch that's in the pull request. The issues I see with rebasing:
I can see a benefit of the Atlantis core making this behaviour configurable and letting users opt-in to the behaviour they desire. But isn't that already available with the custom workflows? I'm open to making it easier to customize this behaviour through a new config schema vs. using the workflows. |
|
Atlantis does store the plan right now. Terraform will error out if the state has been update after the plan was created. I think in the case of a rebase, it should do the initial rebase on plan and store the plan. It shouldn't rebase on apply again. That should still solve the issue you're talking about.
Yeah I can see how that would be annoying and also happen often. Sounds like we need a configurable checkout behaviour that would also allow people to use the github merge commit if they'd rather. Something like Is there any reason people would want to configure this on a per-repo basis rather than a global flag? |
I would think they would want the same workflow on all repos and I agree doing it on the plan makes sense and not doing any rebase on a apply. |
I like the idea of Atlantis merging in master to the branch, and committing it back, before the plan. I would never want it to rebase and commit since we'd lose the commits the developer did. So the code review in the PR wouldn't be clear. |
I don't think the plan was for it to commit the rebase, just do the rebase and use the resulting code for running all the commands. If that's the behaviour you'd like @kipkoan then I think if it used the |
Oh! So Atlantis would run code that is different than what the reviewer of the PR sees in that PR? That sounds like a bad idea to me. I'd rather just be notified that the PR code doesn't have the latest master code merged. I'd rather force the PR to merge master before even being notified that I have a PR to review. |
@kipkoan Jenkins/Travis and other systems all have support for this. |
A build is pretty much 100% safe. Applying terraform is not. It seems safer to me for the reviewer to see the exact terraform that is being plannned before applying it. But, maybe I'm being too cautious, and there aren't any possibly bad repercussions. |
Terraform runs off the desired state. What is in master should be the desired state so based on that you should always have your changes rebased on master. |
Rebasing doesn't matter really. Merging is just as good here. What I want is to have master always reflect what is applied. |
If rebasing vs merging does not matter to you then feel free to ignore that distinction. Without support for this someone could apply a PR and after that PR gets merged to master it may differ. |
Agreed with shane this often this means resource destruction
At my org we have 180+ people in R&D (not all are engineers we have groups such as PMs, data scientists, etc) submitting pull requests to manage github access (creating repos, updating required ci contexts, etc) with varying skillsets and are not generally proficient at terraform and/or git. This morning I had to checkout someone's branch and rebase on their behalf because they could not seem to figure it out, I'd like this to automatically happen assuming no conflicts. If there are conflicts then we can comment a message to the user telling them they need to rebase and fix it manually.
I think we should handle this situation by rebasing, discarding the review, and re-run the plan. We do not need to rebase on apply.
Exactly, on most of my terraform projects (using atlantis and jenkins) I have to rebase an average of 5+ times a day to stay in sync. Either we should only apply from master or we should auto rebase from master, force push the changes (I can easily be talked out of that but I guess my question is why there is resistance to it as it makes a cleaner history and is safer to merge back), discard any reviews, plan, and then follow what we are already doing.
From a terraform/atlantis perspective its not a issue but if you like clean git history, merges are uglier as it puts history out of order. |
Another option which is supported by https://dependabot.com is to make it an atlantis command for example |
This adds a flag to the CLI to have the PR rebased onto the master branch when the flag
--rebase-repo
is set.I did not implement the configuration for the atlantis.yml as I was not sure if we would want that interaction where once rebased we would have to reread the atlantis.yml.