Issue with Details in cloudstack_instance resource
I have the following in my resource config:
resource "cloudstack_instance" "test_box" {
name = test-box-0
display_name = "test-box-0"
details = {cpuNumber = "4", memory = "4096"}
}
but I get this error when I try to apply. I have tried several different ways and it still fails.
│ Error: Error creating the new instance test-box-0: invalid character '<' looking for beginning of value
│
│ with cloudstack_instance.test_box[0],
│ on main.tf line 46, in resource "cloudstack_instance" "test_box":
│ 46: resource "cloudstack_instance" "test_box" {
I'm running this agains the latest provider version 0.5.0 and on CS 4.19.1.0
@vishesh92 I see the most recent commit that is related to this, and was hoping you might have some insight as to why I'm not able to get this to work?
OK, I believe It has something to do with my firewall it is going through. If I go directly to the CS instance it will work.
HOWEVER: I went to change the memory to a value that is outside of the constrained offering, and it applied it in the TF with NO errors, and did not change anything in the actual cloudstack_instance resource. I would have expected this to return with an error like it does when the instance is being created with values outside the scope of the constrained resources.
Here is the change that should fail because my offering is only for a max of 4G of memory
but it showing it changed, but really didn't do anything to the instance
Still at only 4G of RAM
If I destroy that instance and re-run the TF with the 8G of RAM specified to create the instance it does fail.
and it fails as expected.
Hi @CodeBleu sorry for the offtop, but I just wanted to know, how you managed to make details work.
When I specified custom compute service offering and then set details with proper values I got an error like:
│ Error: Error changing the service offering for instance worker: CloudStack API error 431 (CSExceptionErrorCode: 4350):
| Need to specify custom parameter values cpu, cpu speed and memory when using custom offering
│
│ with worker,
│ on modules/cloudstack/main.tf line 125, in resource "cloudstack_instance" "worker":
│ 125: resource "cloudstack_instance" "worker" {
│
╵
Terraform instance definition has details parameter set like this:
details = { cpuNumber = "8", cpuSpeed = "2000", memory = "6144" }
There is basically no documentation how that should work, maybe any clues?
@chrxmvtik What version of TF and TF Cloudstack provider you using?
Any more info of your "custom offering" might be helpful too.
@chrxmvtik What version of TF and TF Cloudstack provider you using?
Any more info of your "custom offering" might be helpful too.
Of course:
Terraform version: 1.10.1 Cloudstack terraform provider 0.5.0
Custom offering:
Custom offering details:
Name: g1.Custom
ID: 7729006c-c6f6-444e-a6f7-xxxxx
Description: Custom Instance HDD
Offer HA: true
Provisioning type: thin
Storage type: shared
Custom disk size: true
CPU cap: false
Host tags: WBHO
Storage tags: Primary-HDD
Domain: ROOT
Zone: XX
Created: 13 Jul 2024 15:53:40
Dynamic scaling enabled: true
Disk offering strictness: false
Encrypt Root Disk: false
@chrxmvtik if you can use CloudMonkey ( cmk ) it would be helpful to see the other info that the UI doesn't show for the offering.
So far, nothing is standing out to me, but it would be helpful to see more detail on how the offering is setup.
cmk list serviceofferings --filter name="g1.Custom"
Also, what Cloudstack Ver. are you running?
@chrxmvtik if you can use CloudMonkey ( cmk ) it would be helpful to see the other info that the UI doesn't show for the offering.
So far, nothing is standing out to me, but it would be helpful to see more detail on how the offering is setup.
cmk list serviceofferings --filter name="g1.Custom"Also, what Cloudstack Ver. are you running?
Cloudstack version is 4.19.1.3
Here is result offering info from CMK:
(localcloud) 🐱 > list serviceofferings --filter name="g1.Custom"
{
"count": 1,
"serviceoffering": [
{
"cacheMode": "writeback",
"created": "2024-07-13T16:53:40+0200",
"defaultuse": false,
"diskofferingstrictness": false,
"displaytext": "Custom Instance HDD",
"domain": "ROOT",
"domainid": "687a14xac120002",
"dynamicscalingenabled": true,
"encryptroot": false,
"hasannotations": false,
"hosttags": "WBHO",
"id": "77290x4c9ff2686",
"iscustomized": true,
"issystem": false,
"isvolatile": false,
"limitcpuuse": false,
"name": "g1.Custom",
"offerha": true,
"provisioningtype": "thin",
"rootdisksize": 0,
"serviceofferingdetails": {
"domainid": "1",
"zoneid": "1"
},
"state": "Active",
"storagetags": "Primary-HDD",
"storagetype": "shared",
"zone": "XX",
"zoneid": "730cb3x1399"
}
]
}
Neither do I really see anything suspicious in here, tho.
linking this issue here as I think it's related
@chrxmvtik if you can use CloudMonkey ( cmk ) it would be helpful to see the other info that the UI doesn't show for the offering. So far, nothing is standing out to me, but it would be helpful to see more detail on how the offering is setup.
cmk list serviceofferings --filter name="g1.Custom"Also, what Cloudstack Ver. are you running?Cloudstack version is 4.19.1.3
Here is result offering info from CMK:
(localcloud) 🐱 > list serviceofferings --filter name="g1.Custom" { "count": 1, "serviceoffering": [ { "cacheMode": "writeback", "created": "2024-07-13T16:53:40+0200", "defaultuse": false, "diskofferingstrictness": false, "displaytext": "Custom Instance HDD", "domain": "ROOT", "domainid": "687a14xac120002", "dynamicscalingenabled": true, "encryptroot": false, "hasannotations": false, "hosttags": "WBHO", "id": "77290x4c9ff2686", "iscustomized": true, "issystem": false, "isvolatile": false, "limitcpuuse": false, "name": "g1.Custom", "offerha": true, "provisioningtype": "thin", "rootdisksize": 0, "serviceofferingdetails": { "domainid": "1", "zoneid": "1" }, "state": "Active", "storagetags": "Primary-HDD", "storagetype": "shared", "zone": "XX", "zoneid": "730cb3x1399" } ] }Neither do I really see anything suspicious in here, tho.
- My previous comment was for my initial issue, not our conversation :smile:
- I'm using a custom
constrainedwithminandmaxsettings for CPU and RAM in my offering. Maybe this is a bug with theunconstrainedoffering?
{
"count": 1,
"serviceoffering": [
{
"cacheMode": "none",
"cpuspeed": 2600,
"created": "2024-10-17T15:49:28+0000",
"defaultuse": false,
"diskofferingstrictness": false,
"displaytext": "jwh-customed-constrained",
"dynamicscalingenabled": true,
"encryptroot": false,
"hasannotations": false,
"hosttags": "standard",
"id": "c99c0b1a-ac09-4eb4-a05b-afe5192445d4",
"iscustomized": true,
"issystem": false,
"isvolatile": false,
"limitcpuuse": true,
"name": "jwh-customed-constrained-2-8-2-4",
"offerha": false,
"provisioningtype": "thin",
"rootdisksize": 0,
"serviceofferingdetails": {
"maxcpunumber": "8",
"maxmemory": "4096",
"mincpunumber": "2",
"minmemory": "2048"
},
"state": "Active",
"storagetags": "standard_storage",
"storagetype": "local"
}
]
}
Maybe try using a custom constrained and limit the CPU and RAM like me to see if that works for you.
@chrxmvtik I just tested with an unconstrained offering and get the same error as you when trying to update an existing instance that had a different offering and was going to change it, but if you create the instance from scratch and specify the details, it will work!
I got the same error as you only when I initially tried to change the offering from constrained to unconstrained. If the instance is already using the unconstrained and I try to change the CPU (for example), then it will behave the same as constrained and show no issue it TF apply, but not actually change anything.
I still think this is an upstream issue with apache/cloudstack that needs to be resolved.
@chrxmvtik I just tested with an
unconstrainedoffering and get the same error as you when trying to update an existing instance that had a different offering and was going to change it, but if you create the instance from scratch and specify thedetails, it will work!I got the same error as you only when I initially tried to change the offering from
constrainedtounconstrained. If the instance is already using theunconstrainedand I try to change the CPU (for example), then it will behave the same asconstrainedand show no issue it TF apply, but not actually change anything.I still think this is an upstream issue with apache/cloudstack that needs to be resolved.
Ah yes, thanks! When I created a new instance with g1.Custom service offering then everything worked fine and I was able to define resources using details parameter. Seems like an workaround for a while..
@CodeBleu This issue looks like a duplicate of #58. I have created #158 to fix the update of details for a VM.
@vishesh92 in regards to #158 , I have tested those changes, but still having issues.
Even thought it gives the error it actually applies the settings to state and another Plan will show no changes.
Also when purposely setting values not in the proper range it does not output from the plan/apply command that it's not in range, but gives the same error as above. It also, still applies those settings to state and another plan will come back clean.
Here is the logs from the management server:
2025-02-04 15:04:35,717 DEBUG [c.c.u.AccountManagerImpl] (qtp1789718525-741:ctx-85eea5a8 ctx-d3628ba6 ctx-afc6ef30) (logid:781668f2) Access to VM instance {"id":8428,"instanceName":"i-676-8428-VM","type":"User","uuid":"16eb8cbd-62b2-4b02-82fa-94cdefbc3da2"} granted to Account [{"accountName":"n8widgets","id":676,"uuid":"5216af48-d506-45f6-8cd3-873b5beb6e1f"}] by DomainChecker 2025-02-04 15:04:35,719 DEBUG [o.a.c.u.UserDataManagerImpl] (qtp1789718525-741:ctx-85eea5a8 ctx-d3628ba6 ctx-afc6ef30) (logid:781668f2) Null/empty base64 encoded user data set 2025-02-04 15:04:35,741 ERROR [c.c.a.ApiServer] (qtp1789718525-741:ctx-85eea5a8 ctx-d3628ba6 ctx-afc6ef30) (logid:781668f2) unhandled exception executing api command: [Ljava.lang.String;@255549e0 com.cloud.utils.exception.CloudRuntimeException: Failed to update VM, due to: Invalid memory value, specify a value between 1024 and 65536 at org.apache.cloudstack.api.command.user.vm.UpdateVMCmd.execute(UpdateVMCmd.java:287) at com.cloud.api.ApiDispatcher.dispatch(ApiDispatcher.java:172)
The error is saying it needs to be in the specified range or 1024 -> 65536 for memory, and as you can see it is using 4096