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

Lising tags of a vm returns 400 Bad Request #2356

Open
4 tasks done
AlePini opened this issue Mar 7, 2025 · 3 comments
Open
4 tasks done

Lising tags of a vm returns 400 Bad Request #2356

AlePini opened this issue Mar 7, 2025 · 3 comments
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage

Comments

@AlePini
Copy link

AlePini commented Mar 7, 2025

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

1.11.1

Terraform Provider

2.11.1

VMware vSphere

7.0.3.01900

Description

When trying to apply or destroy a vm on vSphere, it always stop when trying to fetch the state of the vm:

data.archive_file.ansible-playbooks: Reading...
data.archive_file.ansible-playbooks: Read complete after 0s [id=32748e35ca5e536b964d6c273201c125e21f3619]
data.vsphere_datacenter.this: Reading...
data.vsphere_datacenter.this: Read complete after 1s [id=datacenter-21]
data.vsphere_datastore.this: Reading...
data.vsphere_resource_pool.this: Reading...
data.vsphere_network.this: Reading...
data.vsphere_compute_cluster.this: Reading...
data.vsphere_virtual_machine.template: Reading...
data.vsphere_compute_cluster.this: Read complete after 0s [id=domain-c2611949]
data.vsphere_virtual_machine.template: Read complete after 0s [id=423df678-cef2-5f40-b7c8-59b6a9df2ca1]
data.vsphere_network.this: Read complete after 0s [id=dvportgroup-156651]
data.vsphere_resource_pool.this: Read complete after 0s [id=resgroup-3752084]
data.vsphere_datastore.this: Read complete after 0s [id=datastore-4581368]
vsphere_virtual_machine.vm: Refreshing state... [id=423d56ee-e9b3-2d82-9f5f-9fc5cb8c7ef2]

Error: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["messages","com.vmware.vapi.std.errors.unauthenticated"],"default_message":"Could not convert field 'messages' of structure 'com.vmware.vapi.std.errors.unauthenticated'","id":"vapi.bindings.typeconverter.tovalue.struct.field.error"},{"args":["args","com.vmware.vapi.std.localizable_message"],"default_message":"Required field 'args' of structure 'com.vmware.vapi.std.localizable_message' is missing","id":"vapi.bindings.typeconverter.tovalue.struct.field.missing"}]}}

   with vsphere_virtual_machine.vm,
   on main.tf line 1, in resource "vsphere_virtual_machine" "vm":
    1: resource "vsphere_virtual_machine" "vm" {

edit: I'm not defining tags neither in the terraform config, nor in a vm template.
The VM is created successfully regardless of this error.

Affected Resources or Data Sources

resource/vsphere_virtual_machine

Terraform Configuration

resource "vsphere_virtual_machine" "vm" {
  name             = var.hostname
  datastore_id     = data.vsphere_datastore.this.id
  resource_pool_id = data.vsphere_resource_pool.this.id
  folder           = var.folder

  num_cpus = 2
  memory   = 1024
  guest_id = "ubuntu64Guest"

  network_interface {
    network_id   = data.vsphere_network.this.id
    adapter_type = data.vsphere_virtual_machine.template.network_interface_types[0]
  }

  # Primary disk
  disk {
    label            = "${var.hostname}-disk-root"
    thin_provisioned = data.vsphere_virtual_machine.template.disks[0].thin_provisioned
    eagerly_scrub    = data.vsphere_virtual_machine.template.disks[0].eagerly_scrub
    size             = var.root_disk_size == "" ? data.vsphere_virtual_machine.template.disks[0].size : var.root_disk_size
  }

  clone {
    template_uuid = data.vsphere_virtual_machine.template.id
  }

  vapp {
    properties = {
      "user-data" = base64encode(local.cloud_init_config)
      "network-config" = base64encode(local.network_config)
    }
  }

  cdrom {
    client_device = true
  }

  lifecycle {
    ignore_changes = [
      annotation,
      vapp[0].properties,
      clone[0].template_uuid,
      clone[0].customize[0].dns_server_list,
      clone[0].customize[0].network_interface[0]
    ]
  }
}

Debug Output

2025-03-07T11:12:18.583+0100 [INFO]  provider.terraform-provider-vsphere_v2.11.1_x5: 2025/03/07 11:12:18 [DEBUG] CdromRefreshOperation: cdrom.0 (key 3002 at ide:1:0): Skipping read since CDROM is in use for vApp ISO transport: timestamp="2025-03-07T11:12:18.582+0100"
2025-03-07T11:12:18.583+0100 [INFO]  provider.terraform-provider-vsphere_v2.11.1_x5: 2025/03/07 11:12:18 [DEBUG] CdromRefreshOperation: Resource set to write after known device search: (key 3002 at ide:1:0): timestamp="2025-03-07T11:12:18.582+0100"
2025-03-07T11:12:18.583+0100 [INFO]  provider.terraform-provider-vsphere_v2.11.1_x5: 2025/03/07 11:12:18 [DEBUG] CdromRefreshOperation: Probable orphaned CDROM devices:: timestamp="2025-03-07T11:12:18.582+0100"
2025-03-07T11:12:18.583+0100 [INFO]  provider.terraform-provider-vsphere_v2.11.1_x5: 2025/03/07 11:12:18 [DEBUG] CdromRefreshOperation: Resource set to write after adding orphaned devices: (key 3002 at ide:1:0): timestamp="2025-03-07T11:12:18.582+0100"
2025-03-07T11:12:18.583+0100 [INFO]  provider.terraform-provider-vsphere_v2.11.1_x5: 2025/03/07 11:12:18 [DEBUG] CdromRefreshOperation: Refresh operation complete, sending new resource set: timestamp="2025-03-07T11:12:18.582+0100"
2025-03-07T11:12:18.583+0100 [INFO]  provider.terraform-provider-vsphere_v2.11.1_x5: 2025/03/07 11:12:18 [DEBUG] Reading tags for object "vm-5166121": timestamp="2025-03-07T11:12:18.582+0100"
2025-03-07T11:12:18.689+0100 [INFO]  provider.terraform-provider-vsphere_v2.11.1_x5: 2025/03/07 11:12:18 [DEBUG] Tags for object "vm-5166121":: timestamp="2025-03-07T11:12:18.689+0100"
2025-03-07T11:12:18.690+0100 [ERROR] provider.terraform-provider-vsphere_v2.11.1_x5: Response contains error diagnostic: diagnostic_detail="" diagnostic_summary="400 Bad Request: {\"type\":\"com.vmware.vapi.std.errors.invalid_argument\",\"value\":{\"error_type\":\"INVALID_ARGUMENT\",\"messages\":[{\"args\":[\"messages\",\"com.vmware.vapi.std.errors.unauthenticated\"],\"default_message\":\"Could not convert field 'messages' of structure 'com.vmware.vapi.std.errors.unauthenticated'\",\"id\":\"vapi.bindings.typeconverter.tovalue.struct.field.error\"},{\"args\":[\"args\",\"com.vmware.vapi.std.localizable_message\"],\"default_message\":\"Required field 'args' of structure 'com.vmware.vapi.std.localizable_message' is missing\",\"id\":\"vapi.bindings.typeconverter.tovalue.struct.field.missing\"}]}}" tf_proto_version=5.7 tf_provider_addr=provider tf_req_id=4a3d139c-7350-a39c-bc52-aee041083fef tf_resource_type=vsphere_virtual_machine @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_severity=ERROR tf_rpc=ReadResource timestamp="2025-03-07T11:12:18.689+0100"
2025-03-07T11:12:18.690+0100 [ERROR] vertex "vsphere_virtual_machine.vm" error: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["messages","com.vmware.vapi.std.errors.unauthenticated"],"default_message":"Could not convert field 'messages' of structure 'com.vmware.vapi.std.errors.unauthenticated'","id":"vapi.bindings.typeconverter.tovalue.struct.field.error"},{"args":["args","com.vmware.vapi.std.localizable_message"],"default_message":"Required field 'args' of structure 'com.vmware.vapi.std.localizable_message' is missing","id":"vapi.bindings.typeconverter.tovalue.struct.field.missing"}]}}
2025-03-07T11:12:18.690+0100 [ERROR] vertex "vsphere_virtual_machine.vm (expand)" error: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["messages","com.vmware.vapi.std.errors.unauthenticated"],"default_message":"Could not convert field 'messages' of structure 'com.vmware.vapi.std.errors.unauthenticated'","id":"vapi.bindings.typeconverter.tovalue.struct.field.error"},{"args":["args","com.vmware.vapi.std.localizable_message"],"default_message":"Required field 'args' of structure 'com.vmware.vapi.std.localizable_message' is missing","id":"vapi.bindings.typeconverter.tovalue.struct.field.missing"}]}}
2025-03-07T11:12:18.690+0100 [WARN]  Planning encountered errors, so plan is not applyable
Error: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["messages","com.vmware.vapi.std.errors.unauthenticated"],"default_message":"Could not convert field 'messages' of structure 'com.vmware.vapi.std.errors.unauthenticated'","id":"vapi.bindings.typeconverter.tovalue.struct.field.error"},{"args":["args","com.vmware.vapi.std.localizable_message"],"default_message":"Required field 'args' of structure 'com.vmware.vapi.std.localizable_message' is missing","id":"vapi.bindings.typeconverter.tovalue.struct.field.missing"}]}}
  with vsphere_virtual_machine.vm,
  on main.tf line 1, in resource "vsphere_virtual_machine" "vm":
   1: resource "vsphere_virtual_machine" "vm" {
2025-03-07T11:12:18.691+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-03-07T11:12:18.693+0100 [INFO]  provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/hashicorp/vsphere/2.11.1/linux_amd64/terraform-provider-vsphere_v2.11.1_x5 id=49807
2025-03-07T11:12:18.696+0100 [DEBUG] provider: plugin exited

Panic Output

No response

Expected Behavior

Operations should exits without any problem

Actual Behavior

vsphere provider crashes

Steps to Reproduce

  • Create a VM with vsphere_virtual_machine resource
  • Try to create it or destroy it

Environment Details

No response

Screenshots

No response

References

#1819 faced the same issue, but didn't provide any solution. It's mentioned here to check for permission, so I did and my user has admin permission this new vm

@AlePini AlePini added bug Type: Bug needs-triage Status: Issue Needs Triage labels Mar 7, 2025
Copy link

github-actions bot commented Mar 7, 2025

Hello, AlePini! 🖐

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.

@tenthirtyam
Copy link
Collaborator

The content does not seem to match the description since the use of tags is not shown in the reproduction example.

@AlePini
Copy link
Author

AlePini commented Mar 7, 2025

The content does not seem to match the description since the use of tags is not shown in the reproduction example.

That's exactly my point. I'm not defining any kind of tags for this VM, but the error keeps happening regardless.

edit: I've added this info in the issue description

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

2 participants