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

If repo_config_file is not found, plan should just skip #3339

Open
nicarnold-toast opened this issue Apr 19, 2023 · 4 comments
Open

If repo_config_file is not found, plan should just skip #3339

nicarnold-toast opened this issue Apr 19, 2023 · 4 comments
Labels
bug Something isn't working Stale

Comments

@nicarnold-toast
Copy link

nicarnold-toast commented Apr 19, 2023

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

When specifying a repo_config_file override, I would expect if the file does not exist, that the plan would just be skipped over.
This does not happen. Atlantis attempts to plan the project despite there being no repo config. It seems to use the default config (atlantis.yaml)

Reproduction Steps

  • Setup atlantis server with the following configuraion
---
repos:
- id: /.*/
  repo_config_file: atlantis-nonproduction.yaml
  • Setup webhook to an atlantis server.

  • Push to repo without the atlantis-nonproduction.yaml

Logs

Logs
found no atlantis-nonproduction.yaml file

looks like it originates from here: https://github.com/runatlantis/atlantis/blob/main/server/events/project_command_builder.go#L392

Environment details

  • Atlantis version: e0ea4a5f3fa6 <- docker sha
  • Deployment method: ecs
  • If not running the latest Atlantis version have you tried to reproduce this issue on the latest version: n/a
  • Atlantis flags:

Atlantis server-side config file:

---
repos:
- id: /.*/
  repo_config_file: atlantis-test.yaml

Repo atlantis.yaml file:

N/A

Additional Context

@nicarnold-toast nicarnold-toast added the bug Something isn't working label Apr 19, 2023
@GenPage
Copy link
Member

GenPage commented Apr 21, 2023

Hello @nicarnold-toast, thanks for reaching out. That is correct, if no repoConfigFile is found Atlantis will try to autodetect Terraform modules that are modified in the PR.

} else {
// If there is no config file or it specified no projects, then we'll plan each project that
// our algorithm determines was modified.
if hasRepoCfg {
ctx.Log.Info("No projects are defined in %s. Will resume automatic detection", repoCfgFile)
} else {
ctx.Log.Info("found no %s file", repoCfgFile)
}
// build a module index for projects that are explicitly included
modifiedProjects := p.ProjectFinder.DetermineProjects(ctx.Log, modifiedFiles, ctx.Pull.BaseRepo.FullName, repoDir, p.AutoplanFileList, moduleInfo)
ctx.Log.Info("automatically determined that there were %d projects modified in this pull request: %s", len(modifiedProjects), modifiedProjects)
for _, mp := range modifiedProjects {
ctx.Log.Debug("determining config for project at dir: %q", mp.Path)
pWorkspace, err := p.ProjectFinder.DetermineWorkspaceFromHCL(ctx.Log, repoDir)
if err != nil {
return nil, errors.Wrapf(err, "looking for Terraform Cloud workspace from configuration %s", repoDir)
}
automerge := DefaultAutomergeEnabled
parallelApply := DefaultParallelApplyEnabled
parallelPlan := DefaultParallelPlanEnabled
if hasRepoCfg {
automerge = repoCfg.Automerge
parallelApply = repoCfg.ParallelApply
parallelPlan = repoCfg.ParallelPlan
}
pCfg := p.GlobalCfg.DefaultProjCfg(ctx.Log, ctx.Pull.BaseRepo.ID(), mp.Path, pWorkspace)
projCtxs = append(projCtxs,
p.ProjectCommandContextBuilder.BuildProjectContext(
ctx,
cmdName,
subCmdName,
pCfg,
commentFlags,
repoDir,
automerge,
parallelApply,
parallelPlan,
verbose,
p.TerraformExecutor,
)...)
}
}

You are asking for a way to disable this behavior?

@nicarnold-toast
Copy link
Author

Hey @GenPage . Thanks for getting back to me. I think your suggestion around disabling this might be the better option in this case (as it appears this is already an established pattern).

Would you like me to follow up with a PR in this case?

Many thanks,
Nic

@GenPage
Copy link
Member

GenPage commented May 2, 2023

Hello Nic, yes PRs are welcome

@nitrocode
Copy link
Member

nitrocode commented May 7, 2023

A pr for this has already been created and is awaiting review. Please comment and add feedback when time permits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

3 participants