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

fix(workflows): ignore notification trigger order when comparing state #2438

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

IliaShurygin
Copy link
Collaborator

@IliaShurygin IliaShurygin commented Aug 2, 2023

Description

Workflow notification triggers is an ordered set that is currently represented in Terraform as an ordered list.
Our backend does not preserve the order of the given notification triggers.

As a result, if a workflow resource notification trigger does not match the order returned by NR API, Terraform reports a state drift when there isn't any.

This PR makes sure to keep the notification trigger order the same as in the existing state.

I could not use DiffSuppressFunc because notification triggers are a part of another property that itself is a set. Because Terraform uses a hash of the set item as its key, if notification triggers changes, TF thinks that the entire parent set item was removed and then the new one was added. So diff suppressing would only work for the entire parent set property, which is just not really feasible and would be extremely ugly.

Fixes #2433

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

Please delete options that are not relevant.

  • My commit message follows conventional commits
  • My code is formatted to Go standards
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes. Go here for instructions on running tests locally.

How to test this change?

There is an integration test that reproduces the problem.

In order to reproduce the problem manually, you need to create workflow with notification triggers in a "wrong" order.
For example, [CLOSED, ACTIVATED]. Without the fix, the workflow would be successfully applied, but TF would report state drift on plan

@CLAassistant
Copy link

CLAassistant commented Aug 2, 2023

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Nandu-pns Nandu-pns merged commit 7b4210b into newrelic:main Aug 7, 2023
6 checks passed
@IliaShurygin IliaShurygin deleted the better-workflow-diffs branch August 7, 2023 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terraform plan diff reports changes to unchanged newrelic_workflows
4 participants