atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

feat(1259): sort projects based on dependencies

Open juliusdanielherreraglomm opened this issue 3 years ago • 4 comments

This implements: https://github.com/runatlantis/atlantis/issues/1259

feat(1259): atlantis destroy order

While creating the directed acyclic graph, it checks if the terragrunt.hcl file of the stacks contains our destroy flag: # ATLANTIS_PLEASE_DESTROY_STACK

If this flag is found, the corresponding edge will be reverted, i.e. instead of u -> v, we will get v -> u.

feat(1259): topological sort: fix and debugging

  • this will output the dependency graph in *.dot format
  • it will make the plan fail if the TopSort() fails for whatever reason
  • sorting is not necessary when there is just one project
  • dynamic folder/file generation
  • remove some unnecessary else branches
  • add a test for FindProjectNo()
  • and most important: fix FindProjectNo() so that the sorting is correct

@juliusdanielherreraglomm if you can fix the conflicts and add an example of the problem is trying to solve that will be very helpful, thanks.

jamengual avatar Mar 16 '22 15:03 jamengual

@jamengual Sure thing, conflict is fixed.

Example

If you have an atlantis.yaml like this:

version: 3
projects:
- autoplan:
    enabled: true
    when_modified:
    - '*.hcl'
    - '*.tf*'
    - ../4/terragrunt.hcl
  dir: dependency-test/1
- autoplan:
    enabled: true
    when_modified:
    - '*.hcl'
    - '*.tf*'
    - ../3/terragrunt.hcl
  dir: dependency-test/2
- autoplan:
    enabled: true
    when_modified:
    - '*.hcl'
    - '*.tf*'
    - ../1/terragrunt.hcl
  dir: dependency-test/3
- autoplan:
    enabled: true
    when_modified:
    - '*.hcl'
    - '*.tf*'
  dir: dependency-test/4

this patch will plan/apply the changes in this order:

  1. dependency-test/4
  2. dependency-test/1
  3. dependency-test/3
  4. dependency-test/2

(Copied from test)

this is somewhat related https://github.com/runatlantis/atlantis/pull/2055 maybe you guys need to talk

jamengual avatar Mar 16 '22 17:03 jamengual

Any word on this? It would solve a lot of problems for my team's use of this awesome tool.

Thanks for all the work on it!

austinsherron avatar Jun 22 '22 09:06 austinsherron

@juliusdanielherreraglomm we will like to merge this soon and create a prerelease do you think you can address the comments and add a doc with an example of how to use it?

Thanks.

jamengual avatar Oct 27 '22 06:10 jamengual

Test is failing

server/events/project_finder_test.go:599:31: not enough arguments in call to r.ParseRepoCfg

nitrocode avatar Nov 10 '22 02:11 nitrocode

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.

github-actions[bot] avatar Mar 13 '23 01:03 github-actions[bot]