-
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 doesnt use default atlantis.yaml unless a project name is specified with preworkflow hooks #1612
Comments
It now turns out we cannot simply do 'atlantis apply' on PRs. We receive the following error:
|
We have worked around this issue by creating a symlink in all of the workspace directories during the plan operation.
|
I have a similar use case and am also experiencing this bug. |
|
I see what's happening, but it seems that there's a bug in that its happening. if pre_workflow_hooks only run for the folder named after the workflow, then shouldnt the workflow(s) directory be the only directory(s) that atlantis look for when finding the atlantis.yaml? Prior to the hooks, sure the atlantis.yaml would have had to exist in every workflow/workspace as it was part of the repo. But now, this isnt the case and I would argue its a bug. |
Pre workflow hooks do not make any assumptions about your atlantis config, or project setup. You can run any arbitrary script with them. They are meant to run once and stop before atlantis get to configure your projects and run plan/policy_check/apply. If pre workflow hook fails Atlantis doesn't stop its workflow execution. You can make you pre workflow hook do the workspace folders setup, once you generate atlantis.yaml copy the cloned repo into workspace specific folders. Also On a high level here is execution flow:
We would have to execute pre workflows twice in the execution chain in order to make them re-run for each workspace. |
@msarvar Thanks for the the feedback, its been very helpful. However, I still question, why for the optional clone repo for custom workspaces, is it cloning instead of simply copying what was already cloned? I would think this would make for a faster operation and solve the problem where people are expecting the preworkflow hook to do something which impacts their workspace. We have PRs which create over 100 custom workspaces. That's alot of additional cloning operations. Our use of the preworkflow hook is in creating the atlantis.yaml, so we can't somehow add copying it to all the desired workspaces as they dont exist yet. We figured out our workaround by creating a symlink during the plan. I still think i'm missing something in the workflow though. During the initial plan for all the individual workspaces, it is using the values from the default workspace atlantis.yaml. During the apply it doesnt. Why is there a difference? |
We have a similar use-case and we have encountered similar issues as well (running v0.17.0). To clarify the conditions for this to happen are:
Autoplan (when files in projects are modified) and general However there are different combinations of actions that lead to errors
Here is an example repo-config.yaml to reproduce the issue. For illustration purpose this includes an inline generation of an example As mentioned in this discussion these errors can be worked around by dynamically linking back to the Autoplanning and non-targeted planning ( |
Apologies for the extremely confusing title, so let me explain. Running atlantis v0.16.1
We have our repos.yaml configured to generate the atlantis.yaml via preworkflow hooks:
Note: the terragrunt_light script is simply an output parser/eliminator.
This generates an atlantis.yaml file in the default directory beneath the PR# directory. atlantis appears to properly create the file and use it when performing the initial atlantis plan. However, if any specific plans are specified (atlantis plan -w <> -d <>) it fails to read all or certain aspects of the atlantis.yaml. Specifically, we are in the process of updating our terraform version which is specified via the terraform_version field at the workspace level in the atlantis.yaml. The individual project atlantis plan is not using the specified version and falling back to the --default-tf-version.
If we update the preworkflow hook to add the project name to the atlantis.yaml, then it appears that atlantis properly reads in the terraform_version as atlantis plan -p <> commands then properly pull in the correct terraform version.
I also reported issue #1487 and am now wondering if the two are somehow related. Now that we have enabled the project name, I will update that ticket as well once we have a few more plan/applies dont with this new config to know if there is any relevance with the project name being required.
@dmattia Just FYI. Seems this may be something you want to at least update docs/how-to/examples on the generator/integration that the project name should probably be set.
The text was updated successfully, but these errors were encountered: