PagerDuty / terraform-provider-pagerduty

Terraform PagerDuty provider
https://www.terraform.io/docs/providers/pagerduty/
Mozilla Public License 2.0
203 stars 211 forks source link

Provider/pager_duty - rpc error: code = Unavailable desc = transport is closing #181

Open ghost opened 4 years ago

ghost commented 4 years ago

This issue was originally opened by @killabien as hashicorp/terraform#24145. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

v0.12.20

Terraform Configuration Files

resource "pagerduty_escalation_policy" "policy" {
  name      = var.policy_name
  num_loops = var.num_loops
  teams     = [var.policy_teams]

  rule {
    escalation_delay_in_minutes = var.escalation_delay

    target {
      type = var.target_type
      id   = var.escalation_teams
    }
  }
}

module "ooo_policy" {
  source = "./modules/policy"

  policy_name      = "ooo policy"
  num_loops        = 2
  policy_teams     = ""
  escalation_teams = module.bb_team.team_id
  escalation_delay = 10
  target_type      = "schedule_reference"
}

Debug Output

Crash Output

https://gist.github.com/killabien/ef531bef66ad683b4c8ad6a4208c9056

Expected Behavior

It should have applied the changes

Actual Behavior

See the crash log

Steps to Reproduce

  1. terraform init
  2. terraform apply -var="pg_token=xxxxxxxxx"

Additional Context

This plugin used to work fine. I tried destroying all resources and recreate them but it still crashed. I also tried reinstalling Terraform and restarting my computer.

References

wlonkly commented 4 years ago

Was looking around issues here and got curious about this one so I dug through the gist. I can't look into the panic itself right now but I thought it might help others to have the panic trace here, since the gist has a lot of detail.

panic: interface conversion: interface {} is nil, not string

goroutine 67 [running]:
github.com/terraform-providers/terraform-provider-pagerduty/pagerduty.expandTeams(0x19e31c0, 0xc0008636e8, 0x5, 0x19e31c0, 0xc00047bfa0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/pagerduty/resource_pagerduty_escalation_policy.go:225 +0x254
github.com/terraform-providers/terraform-provider-pagerduty/pagerduty.buildEscalationPolicyStruct(0xc00038e4d0, 0x1bef6b8)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/pagerduty/resource_pagerduty_escalation_policy.go:93 +0x2ba
github.com/terraform-providers/terraform-provider-pagerduty/pagerduty.resourcePagerDutyEscalationPolicyCreate(0xc00038e4d0, 0x1aadc60, 0xc000162100, 0x2, 0x25d5ea0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/pagerduty/resource_pagerduty_escalation_policy.go:102 +0x44
github.com/terraform-providers/terraform-provider-pagerduty/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc000162d80, 0xc0006184b0, 0xc00047b200, 0x1aadc60, 0xc000162100, 0x1a46101, 0xc00089f178, 0xc0008a9a10)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/resource.go:305 +0x363
github.com/terraform-providers/terraform-provider-pagerduty/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc000163700, 0xc0008639f0, 0xc0006184b0, 0xc00047b200, 0xc0008abdc8, 0xc000128858, 0x1a47dc0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/provider.go:289 +0x9c
github.com/terraform-providers/terraform-provider-pagerduty/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000140548, 0x1d54460, 0xc0008a1dd0, 0xc0004f33e0, 0xc000140548, 0xc0008a1d70, 0x1a6a4e0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin/grpc_provider.go:885 +0x86a
github.com/terraform-providers/terraform-provider-pagerduty/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x1b70c80, 0xc000140548, 0x1d54460, 0xc0008a1dd0, 0xc0004f3380, 0x0, 0x0, 0x0, 0xc0008a6000, 0x1b8)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5/tfplugin5.pb.go:3189 +0x23e
github.com/terraform-providers/terraform-provider-pagerduty/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002c0000, 0x1d5a680, 0xc00007aa80, 0xc000890600, 0xc00012e720, 0x25aa1e0, 0x0, 0x0, 0x0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/vendor/google.golang.org/grpc/server.go:995 +0x485
github.com/terraform-providers/terraform-provider-pagerduty/vendor/google.golang.org/grpc.(*Server).handleStream(0xc0002c0000, 0x1d5a680, 0xc00007aa80, 0xc000890600, 0x0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/vendor/google.golang.org/grpc/server.go:1275 +0xe02
github.com/terraform-providers/terraform-provider-pagerduty/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc00043a500, 0xc0002c0000, 0x1d5a680, 0xc00007aa80, 0xc000890600)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/vendor/google.golang.org/grpc/server.go:710 +0x9f
created by github.com/terraform-providers/terraform-provider-pagerduty/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/vendor/google.golang.org/grpc/server.go:708 +0xa1

I believe the subsequent RPC errors are because that goroutine paniced.

jleeh commented 4 years ago

I found this error when the during_support_hours and outside_support_hours blocks were nil in the pagerduty_service resource.

Problematic diff within the pagerduty_service resource that resulted in the error:

      ~ incident_urgency_rule {
            type    = "constant"
            urgency = "low"

          + during_support_hours {}

          + outside_support_hours {}
        }

      + support_hours {}
    }

Making sure the diff was:

incident_urgency_rule {
    type    = "constant"
    urgency = "low"
}

Stopped the error.

Like the panic output above, maybe when other variables are nil within the provider, it causes the same error.