Skip to content
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

/.tflint.hcl triggers planning #1061

Closed
unRob opened this issue May 29, 2020 · 4 comments · Fixed by #1075
Closed

/.tflint.hcl triggers planning #1061

unRob opened this issue May 29, 2020 · 4 comments · Fixed by #1075
Labels
feature New functionality/enhancement

Comments

@unRob
Copy link
Contributor

unRob commented May 29, 2020

Hi there! Working on an Atlantis poc at my new job, having a blast! Just noticed that having a top level .tflint.hcl file (or changing it, not sure yet!) will trip DefaultProjectFinder.filterToTerraform into planning

Log:

2020-05-29T16:02:46.620898603Z 2020/05/29 16:02:46+0000 [INFO] middleware.go:38 server: POST /events – from 10.40.4.237:52094
2020-05-29T16:02:46.620929136Z 2020/05/29 16:02:46+0000 [DBUG] events_controller.go:95 server: Handling GitHub post
2020-05-29T16:02:46.620995301Z 2020/05/29 16:02:46+0000 [DBUG] events_controller.go:145 server: Request valid
2020-05-29T16:02:46.6212588Z 2020/05/29 16:02:46+0000 [DBUG] events_controller.go:157 server: Ignoring unsupported event X-Github-Delivery=d6252298-a1c5-11ea-8599-9540d4465ab3
2020-05-29T16:02:46.621268233Z 2020/05/29 16:02:46+0000 [INFO] middleware.go:42 server: POST /events – respond HTTP 200
2020-05-29T16:02:47.67350978Z 2020/05/29 16:02:47+0000 [INFO] middleware.go:38 server: POST /events – from 10.40.4.237:22888
2020-05-29T16:02:47.673537787Z 2020/05/29 16:02:47+0000 [DBUG] events_controller.go:95 server: Handling GitHub post
2020-05-29T16:02:47.674803841Z 2020/05/29 16:02:47+0000 [DBUG] events_controller.go:145 server: Request valid
2020-05-29T16:02:47.675234748Z 2020/05/29 16:02:47+0000 [DBUG] events_controller.go:154 server: Handling as pull request event
2020-05-29T16:02:47.675252001Z 2020/05/29 16:02:47+0000 [INFO] events_controller.go:317 server: Identified event as type "updated"
2020-05-29T16:02:47.675256119Z 2020/05/29 16:02:47+0000 [INFO] events_controller.go:345 server: Executing autoplan
2020-05-29T16:02:47.675272068Z 2020/05/29 16:02:47+0000 [INFO] middleware.go:42 server: POST /events – respond HTTP 200
2020-05-29T16:02:47.675452094Z 2020/05/29 16:02:47+0000 [DBUG] project_command_builder.go:106 some-org/terraform#607: Got workspace lock
2020-05-29T16:02:47.856173338Z 2020/05/29 16:02:47+0000 [DBUG] project_command_builder.go:114 some-org/terraform#607: 8 files were modified in this pull request
2020-05-29T16:02:47.856201813Z 2020/05/29 16:02:47+0000 [DBUG] working_dir.go:81 some-org/terraform#607: Clone directory "/atlantis/repos/some-org/terraform/607/default" already exists, checking if it's at the right commit
2020-05-29T16:02:47.857183205Z 2020/05/29 16:02:47+0000 [DBUG] working_dir.go:108 some-org/terraform#607: Repo was already cloned but is not at correct commit, wanted "65a3fefc6852c46a3707cee8cf02ea3f31b68e9e" got "e33e18092ab29207ba4df230064dbb1143b9eb7b"
2020-05-29T16:02:48.386525468Z 2020/05/29 16:02:48+0000 [INFO] working_dir.go:169 some-org/terraform#607: Creating dir "/atlantis/repos/some-org/terraform/607/default"
2020-05-29T16:02:49.980410859Z 2020/05/29 16:02:49+0000 [DBUG] working_dir.go:235 some-org/terraform#607: Ran: git clone --branch rhidalgo/DO-806/format-lint-validate --depth=1 --single-branch https://someuser:<redacted>@github.com/some-org/terraform.git /atlantis/repos/some-org/terraform/607/default. Output: Cloning into '/atlantis/repos/some-org/terraform/607/default'...
2020-05-29T16:02:49.980445269Z 2020/05/29 16:02:49+0000 [INFO] project_command_builder.go:149 some-org/terraform#607: Found no atlantis.yaml file
2020-05-29T16:02:49.980470763Z 2020/05/29 16:02:49+0000 [INFO] project_finder.go:54 some-org/terraform#607: Filtered modified files to 1 .tf or terragrunt.hcl files: [.tflint.hcl]
2020-05-29T16:02:49.980603066Z 2020/05/29 16:02:49+0000 [INFO] project_finder.go:75 some-org/terraform#607: There are 1 modified project(s) at path(s): .
2020-05-29T16:02:49.98061027Z 2020/05/29 16:02:49+0000 [INFO] project_command_builder.go:151 some-org/terraform#607: Automatically determined that there were 1 projects modified in this pull request: [repofullname=some-org/terraform path=.]
2020-05-29T16:02:49.980614214Z 2020/05/29 16:02:49+0000 [DBUG] project_command_builder.go:153 some-org/terraform#607: Determining config for project at dir: "."
2020-05-29T16:02:49.980617794Z 2020/05/29 16:02:49+0000 [DBUG] global_cfg.go:189 some-org/terraform#607: Building config based on server-side config
2020-05-29T16:02:49.980673878Z 2020/05/29 16:02:49+0000 [DBUG] global_cfg.go:319 some-org/terraform#607: Setting apply_requirements: [] from default server config
2020-05-29T16:02:49.980688703Z 2020/05/29 16:02:49+0000 [DBUG] global_cfg.go:319 some-org/terraform#607: Setting workflow: "default" from default server config
2020-05-29T16:02:49.980693541Z 2020/05/29 16:02:49+0000 [DBUG] global_cfg.go:319 some-org/terraform#607: Setting allowed_overrides: [apply_requirements] from repos[1], id: /.*/
2020-05-29T16:02:49.980697573Z 2020/05/29 16:02:49+0000 [DBUG] global_cfg.go:319 some-org/terraform#607: Setting allow_custom_workflows: false from default server config
2020-05-29T16:02:49.980865235Z 2020/05/29 16:02:49+0000 [INFO] project_command_builder.go:440 some-org/terraform#607: Cannot determine which version to use from terraform configuration, detected 0 possibilities.
2020-05-29T16:02:50.299499056Z 2020/05/29 16:02:50+0000 [INFO] project_locker.go:74 some-org/terraform#607: Acquired lock with id "some-org/terraform/./default"
2020-05-29T16:02:50.299531112Z 2020/05/29 16:02:50+0000 [DBUG] project_command_runner.go:144 some-org/terraform#607: Acquired lock for project
2020-05-29T16:02:50.299534961Z 2020/05/29 16:02:50+0000 [DBUG] working_dir.go:81 some-org/terraform#607: Clone directory "/atlantis/repos/some-org/terraform/607/default" already exists, checking if it's at the right commit
2020-05-29T16:02:50.300435927Z 2020/05/29 16:02:50+0000 [DBUG] working_dir.go:104 some-org/terraform#607: Repo is at correct commit "65a3fefc6852c46a3707cee8cf02ea3f31b68e9e" so will not re-clone
2020-05-29T16:02:50.581174638Z 2020/05/29 16:02:50+0000 [INFO] terraform_client.go:230 some-org/terraform#607: Successfully ran "/usr/local/bin/terraform init -input=false -no-color -upgrade" in "/atlantis/repos/some-org/terraform/607/default"
2020-05-29T16:02:50.88286864Z 2020/05/29 16:02:50+0000 [INFO] terraform_client.go:230 some-org/terraform#607: Successfully ran "/usr/local/bin/terraform workspace show" in "/atlantis/repos/some-org/terraform/607/default"
2020-05-29T16:02:51.282777724Z 2020/05/29 16:02:51+0000 [EROR] terraform_client.go:227 some-org/terraform#607: Running "/usr/local/bin/terraform plan -input=false -refresh -no-color -out \"/atlantis/repos/some-org/terraform/607/default/default.tfplan\"" in "/atlantis/repos/some-org/terraform/607/default": exit status 1
2020-05-29T16:02:51.958017341Z 2020/05/29 16:02:51+0000 [DBUG] command_runner.go:487 some-org/terraform#607: Updating DB with pull results
2020-05-29T16:02:52.044631777Z 2020/05/29 16:02:52+0000 [INFO] middleware.go:38 server: POST /events – from 10.40.2.91:30738
2020-05-29T16:02:52.044670528Z 2020/05/29 16:02:52+0000 [DBUG] events_controller.go:95 server: Handling GitHub post
2020-05-29T16:02:52.045365239Z 2020/05/29 16:02:52+0000 [DBUG] events_controller.go:145 server: Request valid
2020-05-29T16:02:52.045654076Z 2020/05/29 16:02:52+0000 [DBUG] events_controller.go:151 server: Handling as comment event
2020-05-29T16:02:52.045669033Z 2020/05/29 16:02:52+0000 [DBUG] events_controller.go:413 server: Ignoring non-command comment: "Ran Plan for dir: `.` workspace: `defaul..."

Most importantly, log states:

[INFO] project_finder.go:54 some-org/terraform#607: Filtered modified files to 1 .tf or terragrunt.hcl files: [.tflint.hcl]

and plan output fails with Error: No configuration files

I believe a fix could be added to this line, replacing strings.Contains(fileName, ".tf") with strings.HasSuffix(fileName, ".tf").

if !p.isStatefile(fileName) && (strings.Contains(fileName, ".tf") || filepath.Base(fileName) == "terragrunt.hcl") {

If you think it'd be useful, I'd be happy to make this change and update docs to say .terragrunt.hcl is also part of the default set to autoplan.when_modified.

@lkysow
Copy link
Member

lkysow commented May 29, 2020

We use .Contains to also trigger on .tfvars but I think adding a special exception for .tflint.hcl makes sense.

@lkysow lkysow added the feature New functionality/enhancement label May 29, 2020
@remilapeyre
Copy link
Contributor

Maybe using strings.HasSuffix(fileName, ".tf") && strings.HasSuffix(fileName, ".tfvars") would be better? Otherwise the list will grow indefinitely as many tools will need to have their files added.

@lkysow
Copy link
Member

lkysow commented Jun 12, 2020

So far it's just been terragrunt and tflint, so I don't think it's worth breaking backwards compatibility.

@unRob
Copy link
Contributor Author

unRob commented Jun 12, 2020

Have a fix ready in #1075

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants