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

removing runbook_url from newrelic_nrql_alert_condition has no effect #2332

Closed
ghost opened this issue Apr 21, 2023 · 5 comments
Closed

removing runbook_url from newrelic_nrql_alert_condition has no effect #2332

ghost opened this issue Apr 21, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Apr 21, 2023

Terraform Version

Terraform v1.4.5
on darwin_arm64
+ provider registry.terraform.io/newrelic/newrelic v3.20.2

Affected Resource(s)

  • newrelic_nrql_alert_condition

Terraform Configuration

terraform {
  required_providers {
    newrelic = {
      source  = "newrelic/newrelic"
      version = ">= 3.20.2"
    }
  }
}

provider "newrelic" {}

resource "newrelic_alert_policy" "policy" {
  name = "lauri-test"
}

resource "newrelic_nrql_alert_condition" "condition" {
  policy_id   = newrelic_alert_policy.policy.id
  name        = "lauri-test"
  enabled     = false
  runbook_url = "https://example.com/"

  nrql {
    query = "SELECT average(duration) FROM Transaction where appName = 'Your App'"
  }
  warning {
    operator              = "above"
    threshold             = 100
    threshold_duration    = 600
    threshold_occurrences = "ALL"
  }
}

Steps to Reproduce

  1. terraform apply
  2. remove runbook_url from configuration: sed -i '' /runbook_url/d main.tf
  3. terraform apply
  4. terraform apply

Actual Behavior

On step 3, terraform states it will remove runbook_url from the resource.

newrelic_alert_policy.policy: Refreshing state... [id=4288988]
newrelic_nrql_alert_condition.condition: Refreshing state... [id=4288988:31742195]

Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # newrelic_nrql_alert_condition.condition will be updated in-place
  ~ resource "newrelic_nrql_alert_condition" "condition" {
        id                             = "4288988:31742195"
        name                           = "lauri-test"
      - runbook_url                    = "https://example.com/" -> null
        # (15 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

newrelic_nrql_alert_condition.condition: Modifying... [id=4288988:31742195]
newrelic_nrql_alert_condition.condition: Modifications complete after 2s [id=4288988:31742195]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

However, nothing changes on server side: the old runbook_url remains. That can be verified by rerunning terraform apply (step 4) which shows the same change as step 3. I also verified via the NerdGraph API that the resource in question still has runbook_url set to https://example.com/ after this.

Expected Behavior

The removal of runbook_url should happen on server side.

Debug Output

Available upon request; I can't share it publicly.

@pranav-new-relic
Copy link
Member

Hi @lauri-paypay , thanks for reporting this issue. We've been able to reproduce this issue based on the steps you've described, and it looks like the NerdGraph API isn't updating the runbookUrl to null, when it receives a request to do so, when the attribute is removed in the TF configuration (as you've specified).

I also verified via the NerdGraph API that the resource in question still has runbook_url set to https://example.com/ after this.

We shall take this up based on priority, and get it fixed. Thank you!

@pranav-new-relic pranav-new-relic added the bug Something isn't working label Apr 21, 2023
@ghost
Copy link
Author

ghost commented Apr 21, 2023

Hi @pranav-new-relic, thanks for the response. I am not sure the problem is with the API: I tested manually mutating my condition to set runbook_url to null via GraphiQL as follows:

mutation foo {
  alertsNrqlConditionStaticUpdate(accountId: <omitted>, id: 31742195, condition: {runbookUrl: null}) {
    runbookUrl
  }
}

query bar {
  actor {
    account(id: <omitted>) {
      alerts {
        nrqlCondition(id: 31742195) {
          runbookUrl
        }
      }
    }
  }
}

and it seems that successfully removes the url.

@ghost
Copy link
Author

ghost commented Apr 21, 2023

One more note: setting runbook_url to "" via terraform has the exact same behavior (it shows null in plan), but when manipulated/queried via NerdGraph, null and "" values are distinct for runbook_url.

@Nandu-pns
Copy link
Contributor

Nandu-pns commented May 17, 2023

Hi @lauri-paypay, The fix for the issue reported has been rolled out in our latest Terraform provider release version (v3.23.0). Could you please verify and confirm if the issue is resolved and works as expected with the latest release ?

Thanks !

@ghost
Copy link
Author

ghost commented May 23, 2023

Confirmed, the problem is gone in v3.23.0. Thank you!

@ghost ghost closed this as completed May 23, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants