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

Plugin crash for Nutanix Provider due to integer out of range error #589

Open
colcove opened this issue Apr 27, 2023 · 1 comment
Open

Comments

@colcove
Copy link

colcove commented Apr 27, 2023

Nutanix Cluster Information

  • Nutanix Cluster (Prism Element / AOS) - 6.5.1.8
  • Nutanix Prism Central - pc.2022.6.0.1

Terraform Version

v1.4.6

Affected Resource(s)

  • nutanix_virtual_machine

Terraform Configuration Files

terraform {
  required_providers {
    nutanix = {
      source  = "nutanix/nutanix"
      version = "1.8.1"
    }
  }
}

data "nutanix_cluster" "cluster" {
  name = var.cluster_name
}
data "nutanix_subnet" "subnet" {
  subnet_name = var.subnet_name
}

provider "nutanix" {
  username     = var.user
  password     = var.password
  endpoint     = var.endpoint
  insecure     = true
  wait_timeout = 60
}

resource "nutanix_image" "image" {
  name        = "Arch Linux"
  description = "Arch-Linux-x86_64-basic-20210401.18564"
  source_uri  = "https://mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-basic-20230415.143207.qcow2"
}

resource "nutanix_virtual_machine" "vm" {
  name                 = "MyVM from the Terraform Nutanix Provider"
  cluster_uuid         = data.nutanix_cluster.cluster.id
  num_vcpus_per_socket = "2"
  num_sockets          = "1"
  memory_size_mib      = 1024

  disk_list {
    data_source_reference = {
      kind = "image"
      uuid = nutanix_image.image.id
    }
  }

  disk_list {
    disk_size_bytes = 10 * 1024 * 1024 * 1024
    device_properties {
      device_type = "DISK"
      disk_address = {
        "adapter_type" = "SCSI"
        "device_index" = "1"
      }
    }
  }
  nic_list {
    subnet_uuid = data.nutanix_subnet.subnet.id
  }
}

Debug Output

https://gist.github.com/colcove/8d01a5a61c2a7425b14c2d4ef151cc72

Panic Output

Expected Behavior

terraform plan should have showed which resources are to be created, in this case 2 resources (1 image, 1 vm).

Actual Behavior

terraform plan failed and the plugin crashed, due to a value out of range error

Steps to Reproduce

  1. terraform plan

Important Factors

Environment: Using Windows 11, Nutanix Provider 1.8.1
​Workaround found:
The issue is with the "disk_size_bytes" variable. I changed this line to be - disk_size_mib = 10 * 1024 and then ran terraform plan again. This time it was successful.

References

@abhimutant abhimutant added the bug label Sep 25, 2023
@Haroon-Dweikat-Ntx Haroon-Dweikat-Ntx closed this as completed by moving to In Review in Terraform 1.9.6 Oct 1, 2024
@Haroon-Dweikat-Ntx
Copy link
Collaborator

Hi @colcove

This isn't a provider issue, it's related to the Terraform SDK. It often happens when users accidentally install the 32-bit version of Terraform, which can still run on 64-bit systems.

Integer Limitations:

On 32-bit systems, the maximum signed integer is 2,147,483,647 (2³¹ - 1). If you use a value larger than this, like 10,737,418,240 (10¹⁰, ~10 GB), it exceeds the limit. This triggers a strconv.ParseInt error, throwing "value out of range."

The 64-bit version, however, can handle integers up to 9,223,372,036,854,775,807 (2⁶³ - 1), which is why the error doesn't appear when using it.

Solution:

Install the 64-bit version of Terraform to resolve this issue.

For example, if you check your Terraform version and see:

Terraform v1.9.5
on windows_386

You're using the 32-bit version. After downloading the 64-bit version, the output should look like this:

Terraform v1.9.5
on windows_amd64

This will fix the integer limit problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: This is need to review
Development

No branches or pull requests

3 participants