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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datastore:<computed>' has already been deleted or has not been completely create #2117

Open
4 tasks done
shumak80 opened this issue Jan 19, 2024 · 1 comment
Open
4 tasks done
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage

Comments

@shumak80
Copy link

Community Guidelines

  • I have read and agree to the HashiCorp Community Guidelines .
  • Vote on this issue by adding a 馃憤 reaction to the original issue initial description to help the maintainers prioritize.
  • Do not leave "+1" or other comments that do not add relevant information or questions.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Terraform

v1.7.0

Terraform Provider

v2.6.1

VMware vSphere

v7.0.3

Description

Hi,
I鈥檓 using terraform to create virtual machines with hashicorp/vsphere"
So far, there have been no problems creating them for a long time, but since provider version v2.5.0 problems started, now when I try and do everything the same way, the following error appears:
Error: disk.0: ServerFaultCode: The object 'vim.Datastore:' has already been deleted or has not been completely created
Important thing is that I'm using storage_policy_id to assign datastore for created VM and this cause the error above.
I tried to assign datastore by attribute datastore_id or datastore_cluster_id and no problem appeared.

There are mentioned similar issues with same error which were solved in v2.5.1, but not with using VM storage policy to assign datastore.

I've tested my terraform code with provider version 2.4.3 and there were no problems. Since version v2.5.0 the error appears.

Affected Resources or Data Sources

resource/vsphere_virtual_machine

Terraform Configuration

terraform {
  required_version = ">= 0.13.4"
  required_providers {
    vsphere = {
      source = "hashicorp/vsphere"
    }
  }
}

data "vsphere_datacenter" "dc" {
  name = var.datacenter
}

data "vsphere_compute_cluster" "cluster" {
  name          = var.cluster
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_network" "network" {
  name          = var.network_name
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_virtual_machine" "template" {
   name          = var.template_name
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_storage_policy" "storage" {
  name  = var.storage_policy
}
resource "vsphere_virtual_machine" "vm" {
  name                   = var.hostname
  resource_pool_id       = data.vsphere_compute_cluster.cluster.resource_pool_id
    storage_policy_id      = data.vsphere_storage_policy.storage.id
  num_cpus               = var.cpu_number
  memory                 = var.ram_size
  num_cores_per_socket   = var.num_cores_per_socket
  guest_id               = var.guest_id
  folder                 = var.vm_folder
  network_interface {
    network_id = data.vsphere_network.network.id
  }
  disk {
    label            = "disk0"
    size             = var.disk_size_gb
    thin_provisioned = var.thin_provisioned != "" ? var.thin_provisioned : null
    io_reservation   = length(var.io_reservation) > 0 ? var.io_reservation : null
    io_share_level   = length(var.io_share_level) > 0 ? var.io_share_level : "normal"
    io_share_count   = length(var.io_share_level) > 0 && var.io_share_level == "custom" ? var.io_share_count : null
  }

  clone {
    template_uuid = data.vsphere_virtual_machine.template.id
    timeout       = 30

    customize {
      linux_options {
        host_name    = local.host
        domain       = local.domain
        hw_clock_utc = true
      }
      network_interface {
        ipv4_address = local.ip
        ipv4_netmask = local.netmask
      }                                                                                                                            
      ipv4_gateway = var.gateway
    }
  }
  wait_for_guest_net_timeout = var.wait_for_guest_net_timeout
  wait_for_guest_ip_timeout  = var.wait_for_guest_ip_timeout

  dynamic "network_interface" {
    for_each = var.add_network
    content {
      network_id     = data.vsphere_network.add_network[network_interface.key].id
      adapter_type   = lookup(network_interface.value, "adapter_type", null)
      use_static_mac = lookup(network_interface.value, "use_static_mac", null)
      mac_address    = lookup(network_interface.value, "mac_address", null)
    }
  }
}

Debug Output

https://gist.github.com/shumak80/76702ee2e4e765e860b3093e4b91bc5c

Panic Output

no crash.log

Expected Behavior

The terraform should create VM with assigned datastore by storage policy

Actual Behavior

VM is not created with Error: disk.0: ServerFaultCode: The object 'vim.Datastore:' has already been deleted or has not been completely created

Steps to Reproduce

Create VM storage policy with rule to assign VM one datastore.
Create resource vsphere_virtual_machine with attribute storage_policy_id

Environment Details

No response

Screenshots

No response

References

No response

@shumak80 shumak80 added bug Type: Bug needs-triage Status: Issue Needs Triage labels Jan 19, 2024
Copy link

Hello, shumak80! 馃枑

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage
Projects
None yet
Development

No branches or pull requests

1 participant