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

vcd_vm_sizing_policy limits don't allow for unlimited #1243

Closed
DSI-BenThomas opened this issue Apr 1, 2024 · 0 comments · Fixed by #1303
Closed

vcd_vm_sizing_policy limits don't allow for unlimited #1243

DSI-BenThomas opened this issue Apr 1, 2024 · 0 comments · Fixed by #1303
Assignees

Comments

@DSI-BenThomas
Copy link

Hello,

The current code is incorrect in requiring the VM Sizing Policy CPU and Memory limits need to be at least 0, as this completely removes the ability to create policies with unlimited CPU/Memory as per the API.

You can see the section of code here for CPU Limits
https://github.com/vmware/terraform-provider-vcd/blob/1f61f1eb157271cbe9cdd98698503f45148b22c7/vcd/resource_vcd_vm_sizing_policy.go#L94C3-L99C37

"limit_in_mhz": {
			Type:         schema.TypeString,
			ForceNew:     true,
			Optional:     true,
			Description:  "Defines the CPU limit in MHz for a VM. If not defined in the VDC compute policy, CPU limit is equal to the vCPU speed multiplied by the number of vCPUs.",
			ValidateFunc: IsIntAndAtLeast(0),
		}

And here is the API showing that -1 is a valid value

cpuLimit	integer($int64)
The limit of CPU in MHz for the VM on which this policy is applied. -1 means unlimited. This
is optional. If not provided, limit would be equal to the vCPUSpeed multiplied by numCPU.

memoryLimit	integer($int64)
The limit of memory in MB for the VM on which this policy is applied. -1 means unlimited. This
is optional. If not provided, limit would be equal to the configured memory of the VM.

Terraform Version

% tofu -v
OpenTofu v1.6.2
on darwin_amd64
+ provider registry.opentofu.org/vmware/vcd v3.12.0

Affected Resource(s)

  • vcd_vm_sizing_policy

Terraform Configuration Files

resource "vcd_vm_sizing_policy" "vmsizingpolicy1" {
    description = "General Compute | 2 vCPU"
    name        = "General.2vCPU"

    cpu {
        count                 = "2"
        limit_in_mhz          = "-1"
        reservation_guarantee = "0.1"
        shares                = "4000"
        speed_in_mhz          = "2500"
    }

    memory {
        reservation_guarantee = "0.5"
    }
}

Expected Behavior

Using the above config, I'd expect a new VM Sizing policy to be created with CPU Limit set to Unlimited

image

Actual Behavior

An error is printed that -1 is not a valid value as it's less than 0.

│ Error: expected cpu.0.limit_in_mhz to be at least (0), got -1
│ 
│   with vcd_vm_sizing_policy.vmsizingpolicy1,
│   on main.tf line 171, in resource "vcd_vm_sizing_policy" "vmsizingpolicy1":
│  171:         limit_in_mhz          = "-1"

Steps to Reproduce

  1. terraform plan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants