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

Issue with Details in cloudstack_instance resource #148

Open
CodeBleu opened this issue Dec 9, 2024 · 11 comments · May be fixed by #158
Open

Issue with Details in cloudstack_instance resource #148

CodeBleu opened this issue Dec 9, 2024 · 11 comments · May be fixed by #158
Assignees

Comments

@CodeBleu
Copy link
Collaborator

CodeBleu commented Dec 9, 2024

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?

@CodeBleu
Copy link
Collaborator Author

CodeBleu commented Dec 9, 2024

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
image

but it showing it changed, but really didn't do anything to the instance

image

Still at only 4G of RAM
image

If I destroy that instance and re-run the TF with the 8G of RAM specified to create the instance it does fail.
image

and it fails as expected.

image

@chrxmvtik
Copy link

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?

@CodeBleu
Copy link
Collaborator Author

@chrxmvtik What version of TF and TF Cloudstack provider you using?

Any more info of your "custom offering" might be helpful too.

@chrxmvtik
Copy link

@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:
image

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

@CodeBleu
Copy link
Collaborator Author

CodeBleu commented Dec 11, 2024

@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
Copy link

@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.

@CodeBleu
Copy link
Collaborator Author

linking this issue here as I think it's related

@CodeBleu
Copy link
Collaborator Author

@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.

  1. My previous comment was for my initial issue, not our conversation 😄
  2. I'm using a custom constrained with min and max settings for CPU and RAM in my offering. Maybe this is a bug with the unconstrained offering?
{
  "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.

@CodeBleu
Copy link
Collaborator Author

CodeBleu commented Dec 11, 2024

@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
Copy link

@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.

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..

@vishesh92 vishesh92 linked a pull request Jan 24, 2025 that will close this issue
@vishesh92 vishesh92 linked a pull request Jan 24, 2025 that will close this issue
@vishesh92
Copy link
Member

@CodeBleu This issue looks like a duplicate of #58. I have created #158 to fix the update of details for a VM.

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.

4 participants