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

unable to add tags that don't exist #791

Closed
jayntguru opened this issue Jul 24, 2020 · 10 comments
Closed

unable to add tags that don't exist #791

jayntguru opened this issue Jul 24, 2020 · 10 comments

Comments

@jayntguru
Copy link

Terraform Version

Terraform v0.12.26

  • provider.newrelic v2.2.1
  • provider.time v0.5.0

Affected Resource(s)

newrelic_entity_tags

Terraform Configuration Files

resource "newrelic_entity_tags" "foo" {
guid = data.newrelic_entity.foo.guid
tag {
key = "VIP"
values = ["SingleNode"]
}
}

Expected Behavior

Add tag to entity

Actual Behavior

Error Message
Error: expected entity tag VIP to have been updated but was not found

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:
1: Use the above code
2: plan
3: apply

Important Factoids

First time messing with tags vs labels. It doesn't look like you have to create a tag first (and I can't find any documentation on doing it that way.)

@jthurman42
Copy link
Contributor

Tags can take some time to be visible in the system, have you validated after waiting a period of time that they are still missing? I can not reproduce the issue.

@jayntguru
Copy link
Author

I'm a little confused. How will waiting help if terraform won't put them in to begin with?

Regardless I have waited and it still doesn't work.

@sanderblue
Copy link
Contributor

Hi @jayntguru, it's not a Terraform issue here. This particular underlying API has an asynchronous behavior under the hood, hence the mention of a delay of the tag showing up on the entity.

That being said, I couldn't reproduce this issue either. Can you share your data source HCL code that goes with the associated resource?

@jayntguru
Copy link
Author

jayntguru commented Jul 25, 2020

[Edit tried to fix formatting - failed - gave up.]

Here's my slightly sanitized code. It's entirely possible I'm doing something wrong, if I am, I don't know what it is.

resource "newrelic_synthetics_monitor" "ingressserver" {
  name = "cluster Ingress Node -  server"
  type = "SIMPLE"
  frequency = 1
   status = "ENABLED"
   locations = ["minion"]
  uri = "https://server/healthz"
}

resource "newrelic_synthetics_alert_condition" "ingressserver" {
  policy_id = "123456"
  name        = "Check Condition V2 cluster"
  monitor_id  = newrelic_synthetics_monitor.ingressserver.id
}

resource "time_sleep" "ingressserver" {
  depends_on = [newrelic_synthetics_monitor.ingressserver]
  create_duration = "10s"
}

data "newrelic_entity" "server" {
  name = "cluster Ingress Node -  server"
  depends_on = [time_sleep.ingressserver]
}

resource "newrelic_entity_tags" "server" {
   guid = data.newrelic_entity.server.guid

   tag {
        key = "VIP"
        values = ["SingleNode"]
    }

    tag {
        key = "Environment"
        values = ["cluster"]
    }

    tag {
        key = "Tech"
        values = ["Rancher"]
    }
}

What I do not understand is that the plan looks like it's going to do the right thing.

 # newrelic_entity_tags.server will be updated in-place
  ~ resource "newrelic_entity_tags" "server" {
      ~ guid = "valid_looking_guid" -> (known after apply)
        id   = "valid_looking_guid"

      + tag {
          + key    = "Environment"
          + values = [
              + "cluster",
            ]
        }
      + tag {
          + key    = "Tech"
          + values = [
              + "Rancher",
            ]
        }
      + tag {
          + key    = "VIP"
          + values = [
              + "SingleNode",
            ]
        }
    }

Here's what happens on apply -

newrelic_entity_tags.catl0dlin10059: Modifying... [id=valid_looking_id]
newrelic_entity_tags.catl0dlin10059: Still modifying... [id=valid_looking_id 10s elapsed]
Error: expected entity tag Environment to have been updated but was not found
 on create_synthetic_singlenode.tf line 27, in resource "newrelic_entity_tags" "server":
  27: resource "newrelic_entity_tags" "server" {

If it was a timing thing I would expect subsequent runs to be successful. The plan only shows it as reading the alert, not creating it.

@ctrombley
Copy link
Contributor

@jayntguru I'm also unable to reproduce. Can you slap a long create timeout on the newrelic_entity_tags resource and see if that works any better?

resource "newrelic_entity_tags" "server" {
   guid = data.newrelic_entity.server.guid
 
   ...

   timeouts {
      create = "5m"
   }
}

@jayntguru
Copy link
Author

Thanks for the assistance. I tried the timeouts several places in that block and it didn't change anything (still times out after 10 seconds). Possible I'm doing it wrong? It looks like I should be able to just toss it in there and it should work. (?)

I think I did figure out a clue though, when I do the plan I can tell if it will work or not.

This one will work. It's one of the 3 created in the same file. (Two of the three work.)

` # newrelic_entity_tags.SERVER1 will be updated in-place
~ resource "newrelic_entity_tags" "SERVER1" {
~ guid = "GUID" -> (known after apply)
id = "GUID"

    tag {
        key    = "Environment"
        values = [
            "CLUSTER_NAME",
        ]
    }
    tag {
        key    = "Tech"
        values = [
            "Rancher",
        ]
    }

resource "newrelic_synthetics_monitor" "ingress_for_SERVER1" {
tag {
key = "VIP"
values = [
"SingleNode",
]
}
- tag {
- key = "monitorStatus" -> null
- values = [
resource "newrelic_synthetics_monitor" "ingress_for_SERVER1" {
- "Enabled",
] -> null
}
- tag {
- key = "monitorType" -> null
- values = [
- "Ping",
] -> null
}
- tag {
- key = "period" -> null
- values = [
- "1",
] -> null
}
- tag {
- key = "privateLocation" -> null
- values = [
- "PRIVATE_LOCATION",
] -> null
}
}`

Here's one that I can tell won't work (again, one of the three where two worked and one did not.)

`
# newrelic_entity_tags.SERVER2 will be updated in-place
~ resource "newrelic_entity_tags" "SERVER2" {
~ guid = "GUID" -> (known after apply)
id = "GUID"

  + tag {
      + key    = "Environment"
      + values = [
          + "CLUSTER_NAME",
        ]
    }
  + tag {
      + key    = "Tech"
      + values = [
          + "Rancher",
        ]
    }
  + tag {
      + key    = "VIP"
      + values = [
          + "SingleNode",
        ]
    }
}`

Notice how it's missing all of the other tags that should be there? This makes me think the problem is on create or read. I don't think it's on create because the checks look fine in the UI once they are there.

Any clues based on that?

@zlesnr
Copy link
Contributor

zlesnr commented Jul 29, 2020

The removal of the tags that you have not defined is also captured here: #766

In the mean time, ignore the tags that exist on the resource that terraform keeps trying to remove. That said, which tags are you expecting to be added that are not? I don't know if you caught the comment above from @sanderblue, but when terraform makes the call to the API to create the tags, those tags may take a moment to actually get created in the service. So if the API service hasn't created the tags yet before another plan is run, then terraform will try to create them again.

@jayntguru
Copy link
Author

The tags I'm expecting to see added are "environment", "tech" and "vip".

These alerts were created 2 days ago at this point and still don't work. So I don't think it's a timing thing... unless it's something to do with the timing on create. These are all created in the same terraform plan/apply (along with a dozen or so other infra and nrql alerts).

@zlesnr
Copy link
Contributor

zlesnr commented Jul 30, 2020

Hmm, I tested again this morning and it worked within a minute. Using the following manifest:

provider "newrelic" {}

data "newrelic_entity" "app" {
  name = "Dummy App"
}

resource "newrelic_entity_tags" "server" {
   guid = data.newrelic_entity.app.guid

   tag {
        key = "VIP"
        values = ["SingleNode"]
    }

    tag {
        key = "Environment"
        values = ["cluster"]
    }

    tag {
        key = "Tech"
        values = ["Rancher"]
    }
}

I was then able to modify one of the values and that also showed up quicky. Then just to confirm, I was able to verify the tags using the graphql query interface here: https://api.newrelic.com/graphiql

{
  actor {
    entities(guids: "<GUID_GOES_HERE>") {
      tags {
        key
        values
      }
    }
  }
}

I suspect if the tags aren't being added that perhaps something else is going on. From your manifest above, I would certainly expect that the entity cluster Ingress Node - server would be tagged appropriately. Could you confirm the results of the nerdgraph query also please? Terraform seems to be doing the right thing here for me.

@zlesnr
Copy link
Contributor

zlesnr commented Sep 15, 2020

I believe this should be resolved on v2.7.1. If you are still having issues here, feel free to reopen.

@zlesnr zlesnr closed this as completed Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants