russellcardullo / terraform-provider-pingdom

No longer maintained: Terraform provider to manage pingdom resources
MIT License
120 stars 108 forks source link

Incompatibilities with Terraform 0.8.x #6

Closed ksatirli closed 5 years ago

ksatirli commented 7 years ago

Hello @russellcardullo,

just started using Pingdom at $dayJob and would love to use your plugin to have checks generated through Terraform.

The installation works (though I had to use go get instead of go install to actually get the provider / plugin) but a terraform plan fails with the following:

Error configuring: 1 error(s) occurred:

* Incompatible API version with plugin. Plugin version: 3, Ours: 2

I attempted to verify this by running a number of different ways of installing the plugin, but all end in the same error message.

Any pointers into what I could do to make this work?

russellcardullo commented 7 years ago

Thanks for reporting this. I was able to reproduce your issue with a clean build. The issue looks to be due to the latest mainline branch of terraform having a newer plugin protocol version than the stable release. I was able to correct by checking out the 0-8-stable branch of terraform locally before installing:

go get github.com/hashicorp/terraform
cd $GOPATH/src/github.com/hashicorp/terraform
git checkout 0-8-stable
go get github.com/russellcardullo/terraform-provider-pingdom

Could you let me know if this fixes the issue for you?

ksatirli commented 7 years ago

Hey @russellcardullo - thanks!

That worked out beautifully and I now see the expected output:

+ pingdom_check.example
    host:                     "example.com"
    name:                     "my http check"
    notifywhenbackup:         "<computed>"
    port:                     "<computed>"
    resolution:               "5"
    sendnotificationwhendown: "<computed>"
    type:                     "http"
    url:                      "/"

Any thoughts on the work required for terraform-provider-pingdom to be TF 0.9.x compatible? (I do realize this is out of scope for this issue #6)

russellcardullo commented 7 years ago

Hi @ksatirli. It looks like as long as the terraform binary is 0.9.X and the plugin was built against the terraform 0.9.X source everything works out fine. I tested with the latest version 0.9.0-beta2.

Since the 0.9.X line is still in beta it's not clear if there's a good migration path to allow plugins built against >= 0.9.X to work with binary versions < 0.9 or vice versa. It seems from what I can tell from here that there is no intention for it to be backward or forward compatible.

I think what we can do for now is to at least one of (update the docs/use a Makefile/vendor dependencies) to ensure that people building the plugin from scratch can get the right version that works with the latest stable version available as of now (0.8.7). Likely after 0.9.0 is released we'll need to update that accordingly.

ksatirli commented 7 years ago

Thanks @russellcardullo - once I get everything working, I'd be happy to send in a PR to update docs to make it easier for others to get started.

In the meantime, I was wondering if you could provide some thoughts on the following error I am getting when I do a terraform apply (terraform plan works just fine, oddly enough):

panic: runtime error: invalid memory address or nil pointer dereference
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: [signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x151bde5]
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: 
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: goroutine 79 [running]:
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: github.com/russellcardullo/go-pingdom/pingdom.(*Client).Do(0xc42036c120, 0xc42034a200, 0x1592220, 0xc4202d7bd8, 0x0, 0x0, 0x0)
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom:     ~/.go/src/github.com/russellcardullo/go-pingdom/pingdom/pingdom.go:80 +0x65
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: github.com/russellcardullo/go-pingdom/pingdom.(*CheckService).Create(0xc4202d6fc8, 0x19b02a0, 0xc420346380, 0x2, 0x2, 0xc420247520)
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom:     ~/.go/src/github.com/russellcardullo/go-pingdom/pingdom/check.go:65 +0x10b
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: github.com/russellcardullo/terraform-provider-pingdom/pingdom.resourcePingdomCheckCreate(0xc42036c600, 0x15f0980, 0xc42036c120, 0x0, 0x100d22a)
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom:     ~/.go/src/github.com/russellcardullo/terraform-provider-pingdom/pingdom/resource_pingdom_check.go:353 +0x17b
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc42023bb00, 0xc4202c0780, 0xc420369b40, 0x15f0980, 0xc42036c120, 0x1, 0x28, 0xc420353590)
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom:     ~/.go/src/github.com/hashicorp/terraform/helper/schema/resource.go:162 +0x2d0
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0xc42023bb60, 0xc4202c0730, 0xc4202c0780, 0xc420369b40, 0x1b47770, 0x0, 0xc42023bb60)
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom:     ~/.go/src/github.com/hashicorp/terraform/helper/schema/provider.go:212 +0x9b
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Apply(0xc420302dc0, 0xc420369ac0, 0xc4203932c0, 0x0, 0x0)
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom:     ~/.go/src/github.com/hashicorp/terraform/plugin/resource_provider.go:488 +0x57
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: reflect.Value.call(0xc420075080, 0xc4202d6ce0, 0x13, 0x1693bba, 0x4, 0xc42003af20, 0x3, 0x3, 0x0, 0x0, ...)
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom:     /usr/local/Cellar/go/1.8/libexec/src/reflect/value.go:434 +0x91f
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: reflect.Value.Call(0xc420075080, 0xc4202d6ce0, 0x13, 0xc42024c720, 0x3, 0x3, 0x0, 0x0, 0x0)
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom:     /usr/local/Cellar/go/1.8/libexec/src/reflect/value.go:302 +0xa4
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: net/rpc.(*service).call(0xc42034c140, 0xc42034c100, 0xc420326b18, 0xc4202d8b80, 0xc420368c60, 0x158fe60, 0xc420369ac0, 0x16, 0x158fea0, 0xc4203932c0, ...)
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom:     /usr/local/Cellar/go/1.8/libexec/src/net/rpc/server.go:387 +0x144
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom: created by net/rpc.(*Server).ServeCodec
2017/02/23 10:30:32 [DEBUG] plugin: terraform-provider-pingdom:     /usr/local/Cellar/go/1.8/libexec/src/net/rpc/server.go:481 +0x404
2017/02/23 10:30:32 [DEBUG] plugin: ~/.go/bin/terraform-provider-pingdom: plugin process exited
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalWriteState
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalIf
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalWriteState
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalWriteState
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalIf
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalWriteState
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalWriteState
2017/02/23 10:30:32 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* pingdom_check.example: unexpected EOF
2017/02/23 10:30:32 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* pingdom_check.example: unexpected EOF
2017/02/23 10:30:32 [TRACE] [walkApply] Exiting eval tree: pingdom_check.example
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalIf
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalWriteState
2017/02/23 10:30:32 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* pingdom_check.ping_example: unexpected EOF
2017/02/23 10:30:32 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* pingdom_check.ping_example: unexpected EOF
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/02/23 10:30:32 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/02/23 10:30:32 [TRACE] [walkApply] Exiting eval tree: pingdom_check.ping_example
2017/02/23 10:30:32 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* pingdom_check.example_with_alert: unexpected EOF
2017/02/23 10:30:32 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* pingdom_check.example_with_alert: unexpected EOF
2017/02/23 10:30:32 [TRACE] [walkApply] Exiting eval tree: pingdom_check.example_with_alert
2017/02/23 10:30:32 [DEBUG] vertex "meta.count-boundary (count boundary fixup)", got dep: "pingdom_check.example_with_alert"
2017/02/23 10:30:32 [DEBUG] vertex "meta.count-boundary (count boundary fixup)", got dep: "pingdom_check.ping_example"
2017/02/23 10:30:32 [DEBUG] vertex "meta.count-boundary (count boundary fixup)", got dep: "pingdom_check.example"
2017/02/23 10:30:32 [TRACE] Preserving existing state lineage "ca603ffe-caaf-494f-b2f3-1188d0deb199"
2017/02/23 10:30:32 [DEBUG] plugin: waiting for all plugin processes to complete...

!!!!!!!!!!!!!!!!!!!!!!!!!!! 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.

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

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

This happens when using the sample code you posted in README.md#usage:

terraform apply
pingdom_check.example: Creating...
  host:                     "" => "example.com"
  name:                     "" => "my http check"
  notifywhenbackup:         "" => "<computed>"
  port:                     "" => "<computed>"
  resolution:               "" => "5"
  sendnotificationwhendown: "" => "<computed>"
  type:                     "" => "http"
  url:                      "" => "/"
pingdom_check.ping_example: Creating...
  host:                     "" => "example.com"
  name:                     "" => "my ping check"
  notifywhenbackup:         "" => "<computed>"
  port:                     "" => "<computed>"
  resolution:               "" => "1"
  sendnotificationwhendown: "" => "<computed>"
  type:                     "" => "ping"
  url:                      "" => "/"
pingdom_check.example_with_alert: Creating...
  contactids.#:             "" => "1"
  contactids.637163530:     "" => "12345678"
  host:                     "" => "example.com"
  name:                     "" => "my http check"
  notifywhenbackup:         "" => "<computed>"
  port:                     "" => "<computed>"
  resolution:               "" => "5"
  sendnotificationwhendown: "" => "2"
  sendtoemail:              "" => "true"
  type:                     "" => "http"
  url:                      "" => "/"
  uselegacynotifications:   "" => "true"

Error applying plan:

3 error(s) occurred:

* pingdom_check.example: unexpected EOF
* pingdom_check.ping_example: unexpected EOF
* pingdom_check.example_with_alert: unexpected EOF

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

I'm running Terraform v0.8.7 for this and wondering if you get the same error when doing an apply or if I'm doing something wrong.

I've also tried running an apply with no resources made available through this provider and did not get a crash.

russellcardullo commented 7 years ago

@ksatirli I just pushed a few updates to https://github.com/russellcardullo/go-pingdom which may fix your issue. Could you try pulling the latest and let me know if that works?

ksatirli commented 7 years ago

Awesome @russellcardullo! That works for me.

I've tried adding / updating / destroying a few alerts and all work just fine, though I notice that defining contactids throws an error from the (I think) Pingdom API.

I'll write down my findings and send a PR for README.md soon.

Any chance you could push a new release for consumption in TF?

russellcardullo commented 5 years ago

Should be fixed now but happy to reopen if you have any further issues.