hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
618 stars 452 forks source link

Unexpected status code: 400: Error response from vCloud Suite API #608

Closed hmalinov closed 4 years ago

hmalinov commented 6 years ago

Terraform Version

vSphere Provider Version ./terraform version Terraform v0.11.7

vSphere Provider Version

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

resource "vsphere_virtual_machine" "lintessdevrh7-test_tess_elex_be" {
  datastore_id          = "${data.vsphere_datastore.ds1test.id}"
  resource_pool_id      = "${data.vsphere_resource_pool.pool.id}"
  guest_id              = "${data.vsphere_virtual_machine.template_rhel74.guest_id}"
  scsi_type             = "${data.vsphere_virtual_machine.template_rhel74.scsi_type}"

  name          = "lintessdevrh7-test.tess.elex.be"
  num_cpus      = 4
  memory        = 8192

  cpu_hot_add_enabled           = true
  cpu_hot_remove_enabled        = true
  memory_hot_add_enabled        = true
  enable_logging                = true
  sync_time_with_host       = true

  network_interface {
    network_id   = "${data.vsphere_network.network.id}"
    adapter_type = "${data.vsphere_virtual_machine.template_rhel74.network_interface_types[0]}"
  }

  disk {
    label = "lintessdevrh7-test.tess.elex.be.vmdk"
    size = "${data.vsphere_virtual_machine.template_rhel74.disks.0.size}"
    thin_provisioned = "${data.vsphere_virtual_machine.template_rhel74.disks.0.thin_provisioned}"
  }

  lifecycle {
    ignore_changes = ["disk.0.disk_sharing", "disk.0.datastore_id", "datastore_id", "disk.0", "disk.#", "clone.0", "clone.#"]
  }

  clone {
    template_uuid = "${data.vsphere_virtual_machine.template_rhel74.id}"
    timeout = 120 

    customize {
      linux_options {
        host_name = "lintessdevrh7-test"
        domain    = "${var.domain}"
      }

      network_interface {
        ipv4_address = "10.32.49.52"
        ipv4_netmask = 20
      }

      ipv4_gateway = "${var.gateway}"
      dns_server_list = ["${var.dns_servers}"]
      dns_suffix_list = ["${var.domain}"]
    }
  }

  connection {
    type     = "ssh"
    user     = "root"
    password = "${chomp(base64decode(module.global.rootpw))}"
  }

  provisioner "file" {
    source      = "${var.tf_remote_scripts}"
    destination = "${var.tf_remote_scripts_dest}/"
  }

  provisioner "file" {
    source      = "vsphere/global/files/${lookup(module.global.os_repo, "rhel74")}"
    destination = "/etc/yum.repos.d/saltstack.repo"
  }

  provisioner "remote-exec" {
    inline = [
      "chmod 755 ${var.tf_remote_scripts_dest}/${var.tf_remote_exec}",
      "${var.tf_remote_scripts_dest}/${var.tf_remote_exec}"
    ]
  }
}

Expected Behavior

Vmware machine is created

Actual Behavior

Terraform fails after 1h 5m with the following error:

module.vsphere.vsphere-tess.vsphere_virtual_machine.lintessdevrh7-test_tess_elex_be: Still creating... (1h5m20s elapsed)
module.vsphere.vsphere-tess.vsphere_virtual_machine.lintessdevrh7-test_tess_elex_be: Still creating... (1h5m30s elapsed)
module.vsphere.vsphere-tess.vsphere_virtual_machine.lintessdevrh7-test_tess_elex_be: Still creating... (1h5m40s elapsed)
module.vsphere.vsphere-tess.vsphere_virtual_machine.lintessdevrh7-test_tess_elex_be: Still creating... (1h5m50s elapsed)
module.vsphere.vsphere-tess.vsphere_virtual_machine.lintessdevrh7-test_tess_elex_be: Still creating... (1h6m0s elapsed)
module.vsphere.vsphere-tess.vsphere_virtual_machine.lintessdevrh7-test_tess_elex_be: Still creating... (1h6m10s elapsed)
module.vsphere.vsphere-tess.vsphere_virtual_machine.lintessdevrh7-test_tess_elex_be: Still creating... (1h6m20s elapsed)
module.vsphere.vsphere-tess.vsphere_virtual_machine.lintessdevrh7-test_tess_elex_be: Still creating... (1h6m30s elapsed)
module.vsphere.vsphere-tess.vsphere_virtual_machine.lintessdevrh7-test_tess_elex_be: Still creating... (1h6m40s elapsed)

Error: Error applying plan:

1 error(s) occurred:

* module.vsphere.module.vsphere-tess.vsphere_virtual_machine.lintessdevrh7-test_tess_elex_be: 1 error(s) occurred:

* vsphere_virtual_machine.lintessdevrh7-test_tess_elex_be: Get unexpected status code: 400: Error response from vCloud Suite API: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"messages":[{"args":["com.vmware.cis.tagging.tag_association.list_attached_tags"],"default_message":"Unable to validate input to method com.vmware.cis.tagging.tag_association.list_attached_tags","id":"vapi.invoke.input.invalid"},{"args":["operation-input","object_id"],"default_message":"Structure 'operation-input' is missing a field: object_id","id":"vapi.data.structure.field.missing"}]}}

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

The vmware template was increased from 100GB to 400GB, however the image is created with Packer and it is only 1GB in size.

murloc-muga commented 5 years ago

The tagsClient of VSphereClient seems timeout. If the session is no longer valid and the session needs to be re-saved, Login should be called again before calling SessionID to extract the new session ID. Use the Valid method to check session validity.

if !client.Valid(ctx) {
    client.Login(ctx)
}

add to readTagsForResource func

hashibot commented 4 years ago

This issue has been open 180 days with no activity. If this issue is reproducible with the latest version of the provider and with Terraform 0.12, please comment. Otherwise this issue will be closed in 30 days.

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!