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

Creating workflow for multiple emails always detects changes to apply #551

Closed
mariuszniemiec-wl opened this issue Nov 7, 2023 · 12 comments
Labels
bug/diff kind/bug related to Pulumi generating wrong diffs on preview or up. kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team

Comments

@mariuszniemiec-wl
Copy link

What happened?

I tried to create notification workflow, with use of emails list from configuration (see code below).
However pulumi always see diff in destination IDs array like shown in example below.

Used resources are:

newrelic.NotificationDestination
newrelic.NotificationChannel

newrelic.synthetics.CertCheckMonitor
newrelic.synthetics.Monitor

newrelic.AlertPolicy

newrelic.synthetics.AlertCondition

newrelic.Workflow

Problem is in diff that creates Workflow resource.

Example

Following code:

const notificationEmails: string[] = config.requireObject<string[]>("notificationEmails")
let destinationIds: any[] = [];

// building destinations IDs from email list:
notificationEmails.map((email: string) => {

  const alertDest = new newrelic.NotificationDestination(`${client}-alertDest-${email}`, {
      name: getNameWithConvention(`Alert ${email}`),
      type: 'EMAIL',
      active: true,
      properties: [
          {
              key: 'email',
              value: email,
          },
      ],
  });

  const alertChannel = new newrelic.NotificationChannel(`${client}-alertChannel-${email}`, {
      name: getNameWithConvention(`Alert channel`),
      destinationId: alertDest.id,
      product: "IINT",
      properties: [
      ],
      type: "EMAIL",
  });
  
  destinationIds.push({
      channelId: alertChannel.id,
  });
})

const alertNotificationWorkflow = new newrelic.Workflow("alertNotificationWorkflow", {
    name: `[${client}] Notification workflow`,
    mutingRulesHandling: "NOTIFY_ALL_ISSUES",
    issuesFilter: {
        name: "Filter-name",
        type: "FILTER",
        predicates: [{
            attribute: "labels.policyIds",
            operator: "EXACTLY_MATCHES",
            values: [
                alertPolicy.id
            ],
        }],
    },
    destinations: destinationIds,
});

Pulumi preview, always show (even after up and applying changes):

Previewing update (dev):
 Type                        Name                         Plan       Info
 pulumi:pulumi:Stack         pulumi-newrelic-dev             
~   └─ newrelic:index:Workflow  alertNotificationWorkflow    update     [diff: ~destinations]
...
~ destinations: [
  ~ [0]: {
          ~ channelId: "ID1" => "ID2"
        }
  ~ [1]: {
          ~ channelId: "ID2" => "ID1"
        }
]

Output of pulumi about

CLI
Version 3.92.0
Go Version go1.21.3
Go Compiler gc

Plugins
NAME VERSION
newrelic 5.15.2
nodejs unknown

Host
OS ubuntu
Version 22.04
Arch x86_64

This project is written in nodejs: executable='/bin/node' version='v16.20.2'

Current Stack: organization/pulumi-newrelic-widelab/dev

TYPE URN
pulumi:pulumi:Stack urn:pulumi:dev::pulumi-newrelic-widelab::pulumi:pulumi:Stack::pulumi-newrelic-widelab-dev
pulumi:providers:newrelic urn:pulumi:dev::pulumi-newrelic-widelab::pulumi:providers:newrelic::default_5_15_2
newrelic:index/notificationDestination:NotificationDestination urn:pulumi:dev::pulumi-newrelic-widelab::newrelic:index/notificationDestination:NotificationDestination::[email protected]
newrelic:synthetics/monitor:Monitor urn:pulumi:dev::pulumi-newrelic-widelab::newrelic:synthetics/monitor:Monitor::httpMonitor
newrelic:synthetics/certCheckMonitor:CertCheckMonitor urn:pulumi:dev::pulumi-newrelic-widelab::newrelic:synthetics/certCheckMonitor:CertCheckMonitor::sslMonitor
newrelic:index/alertPolicy:AlertPolicy urn:pulumi:dev::pulumi-newrelic-widelab::newrelic:index/alertPolicy:AlertPolicy::notificationPolicy
newrelic:index/notificationDestination:NotificationDestination urn:pulumi:dev::pulumi-newrelic-widelab::newrelic:index/notificationDestination:NotificationDestination::[email protected]
newrelic:index/notificationChannel:NotificationChannel urn:pulumi:dev::pulumi-newrelic-widelab::newrelic:index/notificationChannel:NotificationChannel::[email protected]
newrelic:synthetics/alertCondition:AlertCondition urn:pulumi:dev::pulumi-newrelic-widelab::newrelic:synthetics/alertCondition:AlertCondition::sslAlertCondition
newrelic:synthetics/alertCondition:AlertCondition urn:pulumi:dev::pulumi-newrelic-widelab::newrelic:synthetics/alertCondition:AlertCondition::httpAlertCondition
newrelic:index/notificationChannel:NotificationChannel urn:pulumi:dev::pulumi-newrelic-widelab::newrelic:index/notificationChannel:NotificationChannel::[email protected]
newrelic:index/workflow:Workflow urn:pulumi:dev::pulumi-newrelic-widelab::newrelic:index/workflow:Workflow::alertNotificationWorkflow

Found no pending operations associated with dev

Backend
Name mario
URL file://~/Work/pulumi-states/pulumi-newrelic-widelab
User mario
Organizations
Token type personal

Dependencies:
NAME VERSION
@types/node 16.18.59
@pulumi/newrelic 5.15.2
@pulumi/pulumi 3.92.0

Pulumi locates its logs in /tmp by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@mariuszniemiec-wl mariuszniemiec-wl added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Nov 7, 2023
@mikhailshilkov mikhailshilkov added bug/diff kind/bug related to Pulumi generating wrong diffs on preview or up. and removed needs-triage Needs attention from the triage team labels Nov 10, 2023
@estiller
Copy link

estiller commented Apr 5, 2024

Hi,
I ran into the same issue. I'd like to highlight that this is caused for any notification channel, not just emails, even if you have only one destination. Using code similair to the above, but with only one notification channel, we get the following output:

    ~ newrelic:index/workflow:Workflow: (update)
        [id=421f4ca7-3d80-467b-a336-bebad05bc864]
        [urn=urn:pulumi:prod::dashboards::newrelic:index/workflow:Workflow::AWS-svc-workflow]
        [provider=urn:pulumi:prod::dashboards::pulumi:providers:newrelic::default_5_22_1::ac23155b-b704-4150-b8e7-087cbaff2c31]
      ~ destinations: [
          ~ [0]: {
                  ~ channelId: "ID1" => "ID1"
                }
        ]

This happens on every run.

I assume it is related to the following issues on the Terraform Bridge project -

Runtime information:

❯ pulumi about
CLI          
Version      3.112.0
Go Version   go1.22.1
Go Compiler  gc

Plugins
NAME      VERSION
newrelic  5.22.1
nodejs    unknown

Host     
OS       darwin
Version  14.2.1
Arch     arm64

This project is written in nodejs: executable='/REDACTED/node' version='v16.20.2'

Backend        
Name           REDACTED
URL            REDACTED
User           REDACTED
Organizations  
Token type     personal

Dependencies:
NAME              VERSION
@pulumi/newrelic  5.22.1
@pulumi/pulumi    3.112.0
prettier          3.2.5
ts-node           10.9.2
@types/node       16.18.94

Is there a possible workaround to this?

@jodem
Copy link

jodem commented Jun 6, 2024

For posterity I had the same issue with properties of both NotificationDestination and NotificationChannel, a change was always detected. Not sure it helps for the current problem but for those poor fellow loving the satisfying "no change detected" who may end up in the thread with a similar problem.

It turned out it was the bridge adding this extra property every time :

{ 
    key: "source",
   label: "terraform-source-internal",
   value: "terraform"
}

simply adding it to the property array 1rst position made no more change detected.

@estiller
Copy link

@jodem, can you elaborate on where you added this value?
A short code snippet would be highly appreciated. Thanks!

@jodem
Copy link

jodem commented Jun 12, 2024

@estiller sure,

As I said it's on the notification destination object I had a change detected all the time until I added an extra property.

const teamsNotificationDestination = new newrelic.NotificationDestination(`${args.cluster.id}-teams-notification`, {
                name: `project-${pulumi.getStack()}-${args.cluster.id} ms teams notif dest`,
                active: true,
                properties: [
                    { // I add to add this because it's added by the tf bridge and detected as change every time
                        key: "source",
                        label: "terraform-source-internal",
                        value: "terraform"
                    }, {
                        key: "url",
                        value: args.defaultTeamsWebhookUrl
                    }],
                accountId: args.nrAccountId,
                type: "WEBHOOK"
            }, { provider: newrelicProvider, parent: this });

@estiller
Copy link

Thanks, @jodem. In our case, we use a Slack destination, so it's manually created, and we can't modify it in code.

@mjeffryes mjeffryes added the needs-triage Needs attention from the triage team label Jul 16, 2024
@iwahbe
Copy link
Member

iwahbe commented Jul 17, 2024

Hi @mariuszniemiec-wl. Thanks for opening an issue. I suspect that this is a bridge that has to do with set diffs. This might have improved in more modern version of pulumi-newrelic. Has anyone replicated the issue on a recent version of pulumi-newrelic?

Edit: pulumi-cloudflare -> pulumi-newrelic

@iwahbe iwahbe removed the needs-triage Needs attention from the triage team label Jul 17, 2024
@estiller
Copy link

estiller commented Jul 19, 2024

Hi @iwahbe, I assume you mean "more modern version of pulumi-newrelic" and not pulumi-cloudflare. I tested our scenario today with the newest version, and it still happens, although now it shifted to another place.

                ~ newrelic:index/notificationChannel:NotificationChannel: (update)
                    [id=xxx]
                    [urn=xxx]
                    [provider=urn:pulumi:prod::infra-newrelic::pulumi:providers:newrelic::default_5_27_0::46dbe63c-fc4c-4482-bfb1-42085bf03f3b]
                  ~ properties: [
                      ~ [0]: {
                              + __defaults  : []
                              - displayValue: ""
                              ~ key         : "source" => "channelId"
                              - label       : "terraform-source-internal"
                              ~ value       : "terraform" => "C06A3HB9UJW"
                            }
                      - [1]: {
                              - displayValue: ""
                              - key         : "channelId"
                              - label       : ""
                              - value       : "C06A3HB9UJW"
                            }
                    ]

This keeps happening, no matter how many times I try deploy.

The workaround mentioned by @jodem solves this.

@iwahbe
Copy link
Member

iwahbe commented Jul 19, 2024

@estiller I did mean "pulumi-newrelic". Sorry about that.

Thanks for checking that this still occurs.

@mariuszniemiec-wl
Copy link
Author

sorry for late answer, I had no time to answer earlier. I confirm issue is stil here, I updated all node package.json including main pulumi as well as pulumi-newrelic.

@iwahbe iwahbe added the awaiting-feedback Blocked on input from the author label Sep 17, 2024
@iwahbe
Copy link
Member

iwahbe commented Sep 17, 2024

Hi @mariuszniemiec-wl. Does the issue still reproduce on v5.32.1? We just released an improvement to this providers diff implementation, and it fixed a similar problem.

@estiller
Copy link

I can confirm the latest version solved the issue for me (described here and here).

@pulumi-bot pulumi-bot added needs-triage Needs attention from the triage team and removed awaiting-feedback Blocked on input from the author labels Sep 23, 2024
@mariuszniemiec-wl
Copy link
Author

mariuszniemiec-wl commented Sep 24, 2024

Wonderful and big thanks. This now works as expected. 🎉
I'm closing it, as also other people confirmed a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/diff kind/bug related to Pulumi generating wrong diffs on preview or up. kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team
Projects
None yet
Development

No branches or pull requests

7 participants