tofu-controller icon indicating copy to clipboard operation
tofu-controller copied to clipboard

Unnecessary Terraform Planning Object Creation in Branch Planner

Open chanwit opened this issue 2 years ago • 4 comments
trafficstars

The current behavior of the branch planner is that it creates a terraform object whenever a PR is created, regardless of the type or scope of the changes in the PR. This means even minor changes like updating a README.md (which isn't managed by Terraform) results in the creation of a terraform object, which the system then continues to reconcile.

The branch planner should be improved to check the nature of the changes in a PR. If the changes do not concern Terraform-managed code (.tf files) or objects (.yaml files), then there's no need to create a terraform object.

chanwit avatar Aug 24 '23 16:08 chanwit

additional possible bug:

when updating variable in terraform object like :

 path: ./terraform/stack/abc-test
  sourceRef:
    kind: GitRepository
    name: abckconfig
    namespace: flux-system
  vars:
    - name: env
      value: qa
    - name: backup_retention_days
      value: "7"
 path: ./terraform/stack/abc-test
  sourceRef:
    kind: GitRepository
    name: abckconfig
    namespace: flux-system
  vars:
    - name: env
      value: qa
    - name: backup_retention_days
      value: "15"

it does not get reflected in new terraform object created by branch planner. Hence it gives no changes in Infrastructure in PR comment.

abc-test-qa-trying-change-in-qa-73   True      No drift: trying-change-in-qa@sha1:02c6a013e5e74a3a6e8208147f4bf60bf09021bb   21m

navpreet-securitas avatar Aug 29 '23 11:08 navpreet-securitas

@navpreet-securitas I have this exact issue and just created a bug about it!

cybercyst avatar Aug 30 '23 21:08 cybercyst

@navpreet-securitas @cybercyst Thanks for the addition.

I'll file it as a separate one.

chanwit avatar Aug 31 '23 03:08 chanwit

One proposed solution in #846 was to use labels to filter PRs when activating the branch planning mode.

lasomethingsomething avatar Nov 02 '23 13:11 lasomethingsomething