-
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
Run plan/apply for multiple projects in parallel #260
Comments
We have some repos that works on >10 AWS accounts (each account is a project in atlantis.yaml). When making a change to all the accounts, Atlantis is painfully show while it sequentially works on every account. We expect this usage to increase, by the way. |
I can certainly see the value in this but I think we need to be careful as to how this is introduced. While in the case of aws providers rate limits are more mitigated as most of their api limits are gated at the account level and rate limit awareness is built in but this is not true of all (or even most) providers. For example we use the github provider to manage teams, repos, etc. We have something like 30+ states/projects and if we ran them all at once it would most certainly fail. |
Could you make this opt in? I'm dealing with about 50 RDS instances right now, each in their own projects - and need to enable multi-az, change instance type, etc. in different steps. This is incredibly slow waiting for each to happen 1 at a time. My other alternative would be to make 50 separate PRs to "fake" the parallelization but that's tricky to manage as well. |
To better understand the use cases where this is important would it be something that makes sense as adhoc on PRs, repo config, server config, or yes? I am leaning towards it be adhoc on PRs as needed or repo config. |
I’m not too familiar with the distinction between repo config and server config, but it seems it would make sense to have a way to set the default behavior as well as enable or disable on an adhoc basis within a PR. |
👍 - was just about to ask about this. I have a repo with 4 projects and currently waiting on atlantis to finish planning as it's running them sequentially. |
We've been running a simple repo config implementation of parallel plans for a couple weeks in our fork and it's working well: https://github.com/runatlantis/atlantis/compare/v0.8.3..segmentio:v0.8.3-segment0.2.1 Caveat: because Atlantis has internal locks on the workspace name, this only works if all projects in the repo use Terraform Workspaces. Example config:
This is for plans only, I feel that making applies parallel could have unintended side-effects. There's also a flag to set the server-side cap on the # of concurrent goroutines that run per-request via Would love to get this or something similar into upstream |
Will this be considered? |
Yeah that looks like a good solution since it avoids the problem of a lot of refactoring by only applying when using different workspaces. Segment's branch looks pretty diverged though so someone would need to make a clean PR. |
Does that mean we won't be able to parallelize it when not using workspaces? |
Yes. But it's a first step. For not using workspaces the locking needs to be figured out so we don't modify a file-system that's got mutations in progress. |
@lkysow quick question as #926 was recently released under 0.13.0. I am running Atlantis with a custom Terragrunt integration (really similar to the docs example I wanted to leverage the newly introduced I am wondering if I could fool atlantis by setting different workspaces (even though in terragrunt you don't need them) to make atlantis run plans and applies in parallel for prod / stage configs. Is this a bad idea or you guys think that could be a valid workaround ? Looking at the plan output from terragrunt it looks good to me but I was wondering if there is something else I should worry about ?
Thanks for your feedback ! |
Hi @Lowess, the reason this only works for workspaces is because Atlantis clones the repo into a separate directory for each workspace so there is no contention. If you set different workspaces then Atlantis will clone into separate directories so it should work. |
@Lowess i wonder whether you have tried using Terragrunt with Terraform workspaces and how this experiment went? |
Having the same problem, in that I have multiple projects in the same repo, all using different backends, etc. I'm not using any "workspaces" (Terraform definition of such), so everything is the "default" workspace. Parallel plans/apply don't work because it thinks that there's a shared lock in place. The first of 6 projects runs successfully, and the rest are reported that they cannot run because they are locked.
|
+1 it would be awesome if we could plan in parallel multiple projects, assuming they are all on different backends. |
I've faced with the same issue. I use terragrunt without workspaces and I'd like to plan\apply in parallel. |
Finally got a chance to try this out as we added a subset of projects which use Terraform Workspaces. It looks like I missed this caveat though:
I had assumed that it would allow us to plan the subset in parallel, and other projects would continue to function as before, however when we opened a PR with multiple (standard) projects each using the Would it be possible to support this use case? Maybe by supporting the |
If we enable parallel_plan, it would be good to have a configuration item for how many parallel to run. Even a 2x parallel would be a huge relief for us |
A plan for us takes upwards of 30 minutes to execute due to having so many different environments. This isn't conducive to a healthy CI/CD where we want to fail fast. |
This would be an excellent feature to add. Similar to others, when Atlantis is managing multiple separate roots with different backends the serial nature increases execution time tremendously. Even if it were an opt-in feature such that terraform roots/projects could add some sort of |
any news here? :) |
This would be great, in our use case all projects differ in TF state and can absolutely run in parallel. This could be a project-level opt-out (parallel: false). It would save us lots of time. |
Do we have any news on this? We want this feature. |
Did they retract 0.19.3? That's the version I'm running and it works for me |
Isn't this available now via https://www.runatlantis.io/docs/repo-level-atlantis-yaml.html#run-plans-and-applies-in-parallel ? # atlantis.yaml in repo
parallel_plan: true
parallel_apply: true cc: @voidlily @nwsparks @hussainbani @Dawnflash @jamengual @lkysow I would prefer enabling this in the server configuration instead of in each terraform repo but a repo level config for this is better than serial plans and serial applies. |
I can't recall now but there was an issue and a PR that was reverted to allow a parallel plan per dir in each project, which is an issue for repos with many folders per env etc |
if someone has cycles: The code is there, the issue is there and the suggested solution is documented......I mean......you can't have a better head start |
This only works if you've implemented multiple workspaces. Atlantis will attempt to run all your projects in the 'default' workspace in parallel and will fail out most of them because "the default workspace is locked." |
running
|
Ah so the biggest limitation is that if you use parallel plans, it only works for the If you use |
Still not working even with parallel_plan: true.
Our use case is reusing same code but separating states with
|
We also have a folder structure that uses the same terraform root modules for different environments and we pass in I am setting Is there any known workaround at this point for running parallel plans/applies w/o using terraform workspaces or do we need to wait for additional functionality to be implemented? Atlantis is a wonderful tool and we really appreciate all the hard work that has gone into it!! |
OK, I was able to come up with a workaround that seems to be working for my use case (which is described in the comment above):
Example project config:
The custom workflow for
This is not heavily tested but at least initially it seems to be working just fine for allowing parallel You will have the wrong |
Good workaround. So it seems that the escape hatch for doing parallel plans&applies dir non-workspaces in the same root dir can be done by setting a fictitious workspace and then explicitly setting the workspace. I'd imagine changes would need to be made to atlantis to support atlantis locking to reuse a root dir without workspaces. For each lock it places, it should check if a lock if already placed by the same pr for the same dir, for the same atlantis run and if so, it shouldn't throw an error. Seems like a bug. |
It is not needed to explicitly set a workspace as long as you're using the
All that would be necessary would be to allow setting the lockfile name to something other than the We are not using terraform workspaces at all. We have multiple AWS accounts, with a 'hub' account having IAM permissions to assume a specific role (w/ permissions to plan/apply terraform) in each 'spoke' account. Each individual account contains the state resources (s3 bucket/dynamodb table). That setup does not work well with terraform workspaces (i.e., having a workspace per account), where state resources are reused for each workspace. Terraform workspaces are compatible with this setup but don't provide any value so we aren't using them. |
I use one monorepo with workspaces per module and each remote state is one per account. |
A side-note here, is there any issue or plans to support launching plan/apply jobs as k8s jobs? That would solve all issues with multiple projects/workspaces parallelisation. This would require and RWM PV to store plan files, but that's a minor thing IMO and all could be configured from the helm chart. |
but then you still need to have a way to sync the status of the jobs back
to the original PR etc, I do not think is that simple, it will require a
lot of work.
…On Fri, Sep 8, 2023 at 1:53 AM George Zubrienko ***@***.***> wrote:
A side-note here, is there any issue or plans to support launching
plan/apply jobs as k8s jobs? That would solve all issues with multiple
projects/workspaces parallelisation
—
Reply to this email directly, view it on GitHub
<#260 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQ3ERBTUOHWX5JPCZMTWVTXZLMIZANCNFSM4FT5DCAQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I agree it is not a days feat. However that would resolve issues with provider version conflicts, allow almost infinite parallelization level etc. |
I might be able to negotiate some time to get this feature in. We run most of our org workloads using k8s jobs built from code/consumed from CRDs, this kind of feature we have experience with. I can also put forward an architecture proposal for discussion. Before the actual implementation I need a week or two to sort out time allocation for an engineer, and one more thing. I am not very good with lawyer stuff, but I know for sure some commercial IaC vendors use k8s jobs exactly for this. Even though the way I see this implemented in Atlantis would be most likely different, I want to ask internally and here as well, if this can be a problem? |
anyone can use k8s jobs no? As long s we do not use an app that has an incompatible licence we should be good. One thing to keep in mind is that we will need a way to expand this solution to non-k8s workloads, since Atlantis supports both, so any code changes will have to be backwards compatible. |
I was thinking adding this as opt-in feature. If users do not enable it in helm values, then its vanilla mode with current functionality. Wdyt? |
Yes, please propose a design proposal for things like this. We are already attempting to fix the issue with locking/parallel plans with #3345 That mainly focuses on the file system side of things. Adding support for adding K8s jobs as "workers" is completely different. While we do want to trend in a more decentralized manner, it must done so in a way that is carefully architected so that K8s doesn't because a requirement |
Via @psalaberria002, would like Atlantis to run plan and apply in parallel when running a command that needs to run on multiple projects. This would make things much faster.
The text was updated successfully, but these errors were encountered: