-
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
feat: add project to hooks #2882
Conversation
Lot's of stuff broken here, still need to fix merges and small fixes. Focused more on learning that making it work. What I'm trying to do:
What I've found so far:
|
Thanks again for proposing another change! Quite a lot of users use https://github.com/transcend-io/terragrunt-atlantis-config so as much as I'd like this change, we'd need to gate it behind a flag unless we can understand why the execution time cannot be lowered. |
Hey @nitrocode, I believe we can reduce the time if we:
Either the users must run a script to check if the file already exists or we need differentiate the initial hook from the others. |
The
I still do not quite understand why different directories would need to be used if you're solving for running Each workspace could use its own To me the root issue is that we create a new git clone and directory per workspace which is inefficient. Consider this directory structure, single clone, single atlantis.yaml file
I think to make this process more efficient
# atlantis server's repos.yaml
repos:
- id: /.*/
allow_custom_workflows: true
# existing functionality for global workflow hook
pre_workflow_hooks:
- run: |
echo "parallel_plan: true" > atlantis.yaml
workflows:
default:
# potential new functionality could override above or append?
pre_workflow_hooks:
- run: |
echo "parallel_plan: true\nparallel_apply: true" > atlantis.yaml
custom_no_parallel_plans:
# potential new functionality could override above or append?
pre_workflow_hooks:
- run: |
echo "parallel_plan: false" > atlantis.yaml # repo's atlantis.yaml
projects:
- name: terraform-ue1-prod
branch: /main/
dir: terraform
workspace: ue1-prod
workflow: default
- name: terraform-ue2-prod
branch: /main/
dir: terraform
workspace: ue2-prod
workflow: custom_no_parallel_plans
- name: terraform-ue1-dev
branch: /main/
dir: terraform
workspace: ue1-dev
workflow: default
workflows:
default:
# potential new functionality could override above or append?
pre_workflow_hooks:
- run: |
echo "hello world" |
That's up to the user. I'm not saying that Atlantis itself should copy the files, I'm saying that we as users should copy the files to reduce the load if something that is CPU intensive is used, I should have stated that more clearly.
Both also should be up to the user too.
They don't, as I said, workspace don't seem to be a problem at all as I thought in the beginning, they are just part of the path where the hooks/plan runs. the project holds the workspace information. The problem is in the projects directory as stated here. Right now from what I can see each project checkout the entire repository for each plan:
What I'm trying to do is ensure that the hooks run on each project (and consequently in the workspace of each project), right now it will only run on the default project, and that's why the issue #2239 was raised. We definitely can make this process more efficient and with less requests to VCS, but that's another problem, that requires far more changes, in far more places. |
The ticket comment you're linking to points to the PR #2180 (and reverted #2253) which moved to using base32 directories per plan instead of the normal directory which caused an issue of generating the atlantis.yaml file across workspaces. I understand it delves into the issue a bit more too. I believe the root issue here seems to be the re-cloning of the directories. If we can reduce that to a single clone per PR, then the feature you're trying to implement will be much easier to maintain over time. cc: @jamengual thoughts on this? |
@Fabianoshz and I had a chat in slack about this and I think he is aware than reusing the clone and copy is an option. there can only be one Atlantis.yaml per workspace but not per project so copying the Atlantis.yaml from the default workspace to project workspace dir should work. |
Ok, took a look at this and found out why we have one directory for each project, the reason is because the plan file is saved inside the directory of the project, so we can have a scenario where the same resource can be planned in two or more workspaces, which would lead to conflict if we just use the same directory but with a different workspace. I've moved the Another thing we could do is change the plan file name to have a prefix with the workspace name, this could help us avoid conflicts, I'm not sure if this would be feasible because I didn't had enough time to dig the plan/apply code to see how it works. |
Opened a PR trying to reduce the amount of clones here, if we go forward with that I can adjust this one later to use CreateWorkspaceDirectory instead of cloning. |
@Fabianoshz do you think you will have time to finish this? @GenPage have been working on this to document the lock process #3345 |
I will close this since updates have been stale for a long time. |
what
why
references