hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.42k stars 9.51k forks source link

Chef provisioner SIGSEGV #15205

Closed mateusduboli closed 7 years ago

mateusduboli commented 7 years ago

Hi there,

I'm trying to run the chef provisioner in a new aws-instance using terraform. But unfortunately I get a SIGSEGV from the process and can't clearly understand the error.

Terraform Version

Terraform v0.9.8

Affected Resource(s)

Terraform Configuration Files

resource "aws_instance" "graylog-mongodb-1" {
  ami             = "<REDACTED>"
  instance_type   = "t2.micro"
  key_name        = "<REDACTED>"
  security_groups = [ "<REDACTED>" ]
  subnet_id       = "<REDACTED>"
  tags            = { "Name" = "graylog-mongodb-1" }

  provisioner "chef" {
    run_list        = [ "role[infra-graylog-mongodb]" ],
    node_name       = "graylog-mongodb-1"
    server_url      = "<REDACTED>"
    user_name       = "<REDACTED>"
    os_type         = "linux"
    recreate_client = true
    user_key        = "${file("<REDACTED>")}"
    prevent_sudo    = false

    connection {
      type = "ssh"
      user = "<REDACTED>"
      private_key = "${file("<REDACTED>")}"
    }
  }

  connection {
    type = "ssh"
    user = "<REDACTED>"
    private_key = "${file("<REDACTED>")}"
  }
}

Panic Output

https://gist.github.com/mateusduboli/e76654fd462bd8cdf6e3729f70a4aa7c

Expected Behavior

Terraform should provide a friendly error message about the configuration.

Actual Behavior

A SIGSEGV

Steps to Reproduce

  1. Run terraform apply with the hcl provided

Important Factoids

The machine is not accessible from outside, I didn't configured the bastion host needed for it to be accessible.

chrisrlong commented 7 years ago

I just tried to provision a new node, first time with 0.9.8 on windows, i think this is the same thing:

module.legacy_site.aws_instance.mod.2: Still creating... (50s elapsed) module.legacy_site.aws_instance.mod.2: Provisioning with 'chef'... Error applying plan:

1 error(s) occurred:

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. panic: runtime error: invalid memory address or nil pointer dereference 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: [signal 0xc0000005 code=0x0 addr=0x18 pc=0x431f5a9] 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: goroutine 24 [running]: 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: github.com/hashicorp/terraform/builtin/provisioners/chef.applyFn(0x8289e40, 0xc04255f0b0, 0x0, 0x0) 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: /opt/gopath/src/github.com/hashicorp/terraform/builtin/provisioners/chef/resource_provisioner.go:268 +0x14d9 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: github.com/hashicorp/terraform/helper/schema.(Provisioner).Apply(0xc042386140, 0x825f9c0, 0xc042056428, 0xc04205a9b0, 0xc042397a10, 0x0, 0x0) 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/provisioner.go:205 +0x56a 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: github.com/hashicorp/terraform/plugin.(ResourceProvisionerServer).Apply(0xc0422a9ae0, 0xc0421af080, 0xc0421c8748, 0x0, 0x0) 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: /opt/gopath/src/github.com/hashicorp/terraform/plugin/resource_provisioner.go:142 +0x198 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: reflect.Value.call(0xc042412840, 0xc042056410, 0x13, 0x564a125, 0x4, 0xc04273ff20, 0x3, 0x3, 0x0, 0x0, ...) 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: /opt/go/src/reflect/value.go:434 +0x926 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: reflect.Value.Call(0xc042412840, 0xc042056410, 0x13, 0xc04273ff20, 0x3, 0x3, 0x0, 0x0, 0xc0423301e0) 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: /opt/go/src/reflect/value.go:302 +0xab 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: net/rpc.(service).call(0xc0423510c0, 0xc042351040, 0xc04251a598, 0xc042564d00, 0xc042237880, 0x473ccc0, 0xc0421af080, 0x16, 0x473cd00, 0xc0421c8748, ...) 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: /opt/go/src/net/rpc/server.go:387 +0x14b 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: created by net/rpc.(Server).ServeCodec 2017/06/09 15:05:08 [DEBUG] plugin: terraform.exe: /opt/go/src/net/rpc/server.go:481 +0x40b 2017/06/09 15:05:08 [DEBUG] root.legacy_site: eval: terraform.EvalIf 2017/06/09 15:05:08 [DEBUG] root.legacy_site: eval: terraform.EvalUndeposeState 2017/06/09 15:05:08 [DEBUG] root.legacy_site: eval: terraform.EvalWriteDiff 2017/06/09 15:05:08 [DEBUG] root.legacy_site: eval: terraform.EvalApplyPost 2017/06/09 15:05:08 [ERROR] root.legacy_site: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

bdwyertech commented 7 years ago

Seeing something similar as well. Reverted back to 0.9.6 and all was well again, 0.9.7 probably would have been OK but 0.9.6 treated me well 😃

svanharmelen commented 7 years ago

@mateusduboli do you get this error a 100% consistently? As I notice you and @chrisrlong get the same error, but on different lines in the code (on the lines in question the same kind of call is being made).

Also about 20 lines above were your crash occurred, the same call is being made. But it seems at that point in time there was no problem executing that call, but a microsecond later it crashed on the same type of call.

So very curious if you have this error consistently... Thanks!

mateusduboli commented 7 years ago

Yep, it's consistent.

I forgot to say, but I managed to pass the first error specifying the os_type variable.

Em 9 de jun de 2017 17:17, "Sander van Harmelen" notifications@github.com escreveu:

@mateusduboli https://github.com/mateusduboli do you get this error a 100% consistently? As I notice you and @chrisrlong https://github.com/chrisrlong get the same error, but on different lines in the code (on the lines in question the same kind of call is being made).

Also about 20 lines above were your crash occurred, the same call is being made. But it seems at that point in time there was no problem executing that call, but a microsecond later it crashed on the same type of call.

So very curious if you have this error consistently... Thanks!

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/hashicorp/terraform/issues/15205#issuecomment-307489379, or mute the thread https://github.com/notifications/unsubscribe-auth/ABnCudhEfrGOz9MFEEFU81rM0QCRUV4Fks5sCahjgaJpZM4N0twq .

svanharmelen commented 7 years ago

Check, thanks... Will have a closer look after the weekend.

Until that time I guess the best solution is to revert back to 0.9.6

Will keep you posted.

thomasv314 commented 7 years ago

Hiya,

I'm also experiencing this issue consistently on version 0.9.8 and 0.9.7.

0.9.6 works fine. Debug log from broken runs is available here: https://gist.github.com/thomasv314/2b751df8bb2ca28e180b72b0a7e324e2

Thanks!

michael-c-jones commented 7 years ago

Let me add my two cents. My last successfully provisioned hosts were last Thursday, June 8. Logs are nearly identical to those previously posted. @svanharmelen we use remote state; can you comment on the procedure for downgrading ?

joegoggins commented 7 years ago

Bummer. I can't downgrade my Atlas from 0.9.8 to 0.9.6 as recommended. No matter what I do to get my local terraform project to run terraform plan I get this error:

Terraform doesn't allow running any operations against a state
that was written by a future Terraform version. The state is
reporting it is written by Terraform '0.9.8'.

Please run at least that version of Terraform to continue.

I've tried many different things to address this and I'm stumped. If anyone has suggestions on other things to try or what information would be required to file this as a bug, please ping me/let me know!

apparentlymart commented 7 years ago

Hi @joegoggins,

Terraform has this protection because it is not in general safe to use a newer state with an older version. However, this particular combination of versions had no significant state changes, so you can override this protection as follows:

Again, this is not safe in general but should work okay in this scenario due to this particular combination of versions having broadly compatible state structure.

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.