opsgenie / terraform-provider-opsgenie

Terraform OpsGenie provider
https://registry.terraform.io/providers/opsgenie/opsgenie/latest/docs
Mozilla Public License 2.0
104 stars 137 forks source link

opsgenie_alert_policy terraform crash after adding tags #131

Closed 3h4x closed 4 years ago

3h4x commented 4 years ago

Hi! I have problem with using latest version of provider on terraform cloud. Alert policy is crashing when I try to add tags.

Terraform Version

0.12.28

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

resource "opsgenie_alert_policy" "this" {
  name               = var.opsgenie_policy_name
  policy_description = var.opsgenie_policy_description == null ? var.opsgenie_policy_name : var.opsgenie_policy_description
  message            = "{{ message }}"
  //  tags            = toset(concat(var.opsgenie_policy_tags, [var.opsgenie_policy_name]))
  tags = ["test"]

  filter {}
}

Debug Output

Is it possible to do debug on terraform cloud?

Panic Output

Terraform v0.12.28
Initializing plugins and modules...
2020/07/20 15:02:26 [DEBUG] Using modified User-Agent: Terraform/0.12.28 TFC/9396454cc1
opsgenie_alert_policy.this[0]: Modifying... [id=99bbe936-cee2-45bc-adf2-f2a06c01f6f1]

Error: rpc error: code = Unavailable desc = transport is closing

panic: interface conversion: interface {} is []interface {}, not *schema.Set
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: 
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: goroutine 32 [running]:
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: github.com/terraform-providers/terraform-provider-opsgenie/opsgenie.flattenOpsgenieAlertPolicyTags(0xc0000ff420, 0x1054f49, 0x4, 0xe769c0)
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-opsgenie/opsgenie/resource_opsgenie_alert_policy.go:716 +0x1ac
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: github.com/terraform-providers/terraform-provider-opsgenie/opsgenie.resourceOpsGenieAlertPolicyUpdate(0xc0000ff420, 0xe5b240, 0xc00000e100, 0x24, 0x1a3e480)
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-opsgenie/opsgenie/resource_opsgenie_alert_policy.go:463 +0x8f1
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc000436180, 0xc000450410, 0xc0004900a0, 0xe5b240, 0xc00000e100, 0xef3201, 0xc000013760, 0xc00024c060)
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-opsgenie/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/resource.go:311 +0x263
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc000436980, 0xc0000138e0, 0xc000450410, 0xc0004900a0, 0xc000228988, 0xc00009c688, 0xef5020)
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-opsgenie/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/provider.go:289 +0x99
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc00009cae0, 0x129eb00, 0xc0004f6150, 0xc0004fa0c0, 0xc00009cae0, 0xc0004f6150, 0xc0004cda48)
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-opsgenie/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin/grpc_provider.go:885 +0x882
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x1018000, 0xc00009cae0, 0x129eb00, 0xc0004f6150, 0xc0004fa060, 0x0, 0x129eb00, 0xc0004f6150, 0xc000200500, 0x4ed)
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-opsgenie/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5/tfplugin5.pb.go:3189 +0x217
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000c8000, 0x12aadc0, 0xc0000a1980, 0xc0004fe000, 0xc000112270, 0x1a042a0, 0x0, 0x0, 0x0)
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-opsgenie/vendor/google.golang.org/grpc/server.go:995 +0x460
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: google.golang.org/grpc.(*Server).handleStream(0xc0000c8000, 0x12aadc0, 0xc0000a1980, 0xc0004fe000, 0x0)
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-opsgenie/vendor/google.golang.org/grpc/server.go:1275 +0xd3d
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc000098440, 0xc0000c8000, 0x12aadc0, 0xc0000a1980, 0xc0004fe000)
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-opsgenie/vendor/google.golang.org/grpc/server.go:710 +0xa1
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-07-20T15:02:28.402Z [DEBUG] plugin.terraform-provider-opsgenie_v0.3.8_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-opsgenie/vendor/google.golang.org/grpc/server.go:708 +0xa1
2020-07-20T15:02:28.403Z [DEBUG] plugin: plugin process exited: path=/terraform/projects/opsgenie/.terraform/plugins/linux_amd64/terraform-provider-opsgenie_v0.3.8_x4 pid=1594 error="exit status 2"
2020/07/20 15:02:28 [DEBUG] opsgenie_alert_policy.this[0]: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing
2020/07/20 15:02:28 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2020/07/20 15:02:28 [TRACE] <root>: eval: *terraform.EvalWriteState
2020/07/20 15:02:28 [TRACE] EvalWriteState: recording 0 dependencies for opsgenie_alert_policy.this[0]
2020/07/20 15:02:28 [TRACE] EvalWriteState: writing current state object for opsgenie_alert_policy.this[0]
2020/07/20 15:02:28 [TRACE] <root>: eval: *terraform.EvalApplyProvisioners
2020/07/20 15:02:28 [TRACE] EvalApplyProvisioners: opsgenie_alert_policy.this[0] is not freshly-created, so no provisioning is required
2020/07/20 15:02:28 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2020/07/20 15:02:28 [TRACE] <root>: eval: *terraform.EvalWriteState
2020/07/20 15:02:28 [TRACE] EvalWriteState: recording 0 dependencies for opsgenie_alert_policy.this[0]
2020/07/20 15:02:28 [TRACE] EvalWriteState: writing current state object for opsgenie_alert_policy.this[0]
2020/07/20 15:02:28 [TRACE] <root>: eval: *terraform.EvalIf
2020/07/20 15:02:28 [TRACE] <root>: eval: *terraform.EvalIf
2020/07/20 15:02:28 [TRACE] <root>: eval: *terraform.EvalWriteDiff
2020/07/20 15:02:28 [TRACE] <root>: eval: *terraform.EvalApplyPost
2020/07/20 15:02:28 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: rpc error: code = Unavailable desc = transport is closing
2020/07/20 15:02:28 [ERROR] <root>: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2020/07/20 15:02:28 [TRACE] [walkApply] Exiting eval tree: opsgenie_alert_policy.this[0]
2020/07/20 15:02:28 [TRACE] vertex "opsgenie_alert_policy.this[0]": visit complete
2020/07/20 15:02:28 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2020/07/20 15:02:28 [TRACE] dag/walk: upstream of "provider.opsgenie (close)" errored, so skipping
2020/07/20 15:02:28 [TRACE] dag/walk: upstream of "root" errored, so skipping
2020-07-20T15:02:28.404Z [DEBUG] plugin: plugin exited

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

SECURITY WARNING: the "crash.log" file that was created may contain 
sensitive information that must be redacted before it is safe to share 
on the issue tracker.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Expected Behavior

Tag should be added to opsgenie policy.

  # opsgenie_alert_policy.this[0] will be updated in-place
  ~ resource "opsgenie_alert_policy" "this" {
        actions                    = []
        alias                      = "{{alias}}"
        continue_policy            = true
        enabled                    = false
        entity                     = "{{entity}}"
        id                         = "..."
        ignore_original_actions    = false
        ignore_original_details    = false
        ignore_original_responders = false
        ignore_original_tags       = false
        message                    = "{{ message }}"
        name                       = "prometheus"
        policy_description         = "prometheus"
        source                     = "{{source}}"
      ~ tags                       = [
          + "test",
        ]

        filter {
            type = "match-all"
        }
    }

Actual Behavior

Terraform crashed

ffahri commented 4 years ago

Thank you @3h4x, while looking i also noticed two important bug will temp disable some fields and will re-introduce next version

https://github.com/terraform-providers/terraform-provider-opsgenie/pull/132

ffahri commented 4 years ago

sorry for this, alert policy will be revisited, current fix has been sent to production v0.3.9 also added tag field to our e2e tests

3h4x commented 4 years ago

@ffahri Wow. That was quick man :D Thanks! Waiting for next release!