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

vSphere: Crash on minimal configuration #3537

Closed
jwieringa opened this issue Oct 18, 2015 · 7 comments · Fixed by #3636
Closed

vSphere: Crash on minimal configuration #3537

jwieringa opened this issue Oct 18, 2015 · 7 comments · Fixed by #3636

Comments

@jwieringa
Copy link
Contributor

Assuming the following configuration:

provider "vsphere" {
  user           = "${var.vsphere_user}"
  password       = "${var.vsphere_password}"
  vcenter_server = "${var.vsphere_vcenter_server}"
}

resource "vsphere_virtual_machine" "web" {
  name   = "terraform_web"
  vcpu   = 2
  memory = 4096
  network_interface {
    label = "10.112.70.0"
  }
  disk {
    size = 40
  }
}

Successful plan:

➜  terraform git:(master) ✗ terraform plan
Refreshing Terraform state prior to plan...

+ vsphere_virtual_machine.web
    disk.#:                          "" => "1"
    disk.0.size:                     "" => "40"
    domain:                          "" => "vsphere.local"
    memory:                          "" => "4096"
    name:                            "" => "terraform_web"
    network_interface.#:             "" => "1"
    network_interface.0.ip_address:  "" => "<computed>"
    network_interface.0.label:       "" => "10.112.70.0"
    network_interface.0.subnet_mask: "" => "<computed>"
    time_zone:                       "" => "Etc/UTC"
    vcpu:                            "" => "2"


Plan: 1 to add, 0 to change, 0 to destroy.

Terraform crash on apply:

➜  terraform git:(master) ✗ terraform apply
vsphere_virtual_machine.web: Creating...
  disk.#:                          "" => "1"
  disk.0.size:                     "" => "40"
  domain:                          "" => "vsphere.local"
  memory:                          "" => "4096"
  name:                            "" => "terraform_web"
  network_interface.#:             "" => "1"
  network_interface.0.ip_address:  "" => "<computed>"
  network_interface.0.label:       "" => "10.112.24.0"
  network_interface.0.subnet_mask: "" => "<computed>"
  time_zone:                       "" => "Etc/UTC"
  vcpu:                            "" => "2"
Error applying plan:

1 error(s) occurred:

* vsphere_virtual_machine.web: 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.
panic: runtime error: index out of range

VM was successfully created in vSphere after an apply; however, no state was written:

➜  terraform git:(master) ✗ cat terraform.tfstate
{
    "version": 1,
    "serial": 0,
    "modules": [
        {
            "path": [
                "root"
            ],
            "outputs": {},
            "resources": {}
        }
    ]
}
➜  terraform git:(master) ✗ terraform --version
Terraform v0.6.4

Full crash log: https://gist.github.com/jwieringa/f0aa0285ed2570c07399

Please let me know if you have any questions. Any feedback on working through the Go stack trace greatly appreciated, thanks!

@mkuzmin
Copy link
Contributor

mkuzmin commented Oct 20, 2015

Yes, I experience the same issue.

@eloycoto
Copy link
Contributor

Same issue here too.

@mkuzmin
Copy link
Contributor

mkuzmin commented Oct 21, 2015

@tkak any ideas?

@tkak
Copy link
Contributor

tkak commented Oct 25, 2015

It seems to fail to get an IP address because only to create an empty VM in case of minimal configuration. I will fix it.

https://github.com/hashicorp/terraform/blob/master/builtin/providers/vsphere/resource_vsphere_virtual_machine.go#L425

@mkuzmin
Copy link
Contributor

mkuzmin commented Oct 25, 2015

Cloning from a template causes the same result.

At https://github.com/hashicorp/terraform/blob/master/builtin/providers/vsphere/resource_vsphere_virtual_machine.go#L329 you are waiting for Summary.Guest.IpAddress and then access networkInterfaces.
But that happens too early: even if IP address is reported, network adapters are not created yet.

You have changed this logic in rakutentech/terraform-provider-vsphere#29
I suppose using WaitForIP method was a more reliable solution.

@jwieringa
Copy link
Contributor Author

👍 No longer having this issue. Thanks!

@ghost
Copy link

ghost commented Apr 30, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants