-
Notifications
You must be signed in to change notification settings - Fork 48
Fix update of VM details #158
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
base: main
Are you sure you want to change the base?
Conversation
@vishesh92 please see #148 as there are still issues |
@CodeBleu can you be more specific? |
Not sure what else to say. All the details are in #148 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The update virtual machine api is not getting executed correctly
https://cloudstack.apache.org/api/apidocs-4.21/apis/updateVirtualMachine.html
Terraform config
resource "cloudstack_instance" "VM1" {
name = "TERRAFORMVM2"
service_offering = "custom-offering"
template = "f90b3383-7730-11f0-9a5b-1e00900003a2"
network_id = "1eb73b50-1db5-42f5-8938-8592df101d61"
zone = "5ae50b9f-6280-4c4b-9551-ee48da867034"
expunge = true
root_disk_size = 10
details = {"cpuNumber" = "2","cpuSpeed"= "1000", "memory" = "2048"}
}
terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# cloudstack_instance.VM1 will be created
+ resource "cloudstack_instance" "VM1" {
+ details = {
+ "cpuNumber" = "2"
+ "cpuSpeed" = "1000"
+ "memory" = "2048"
}
+ display_name = (known after apply)
+ expunge = true
+ group = (known after apply)
+ id = (known after apply)
+ ip_address = (known after apply)
+ name = "TERRAFORMVM2"
+ network_id = "1eb73b50-1db5-42f5-8938-8592df101d61"
+ project = (known after apply)
+ root_disk_size = 10
+ service_offering = "custom-offering"
+ start_vm = true
+ tags = (known after apply)
+ template = "f90b3383-7730-11f0-9a5b-1e00900003a2"
+ uefi = false
+ zone = "5ae50b9f-6280-4c4b-9551-ee48da867034"
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
cloudstack_instance.VM1: Creating...
cloudstack_instance.VM1: Creation complete after 8s [id=95b67d96-8868-481f-a7c0-32d59a2d3a76]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Now change the details cpuNumber and memory
resource "cloudstack_instance" "VM1" {
name = "TERRAFORMVM2"
service_offering = "custom-offering"
template = "f90b3383-7730-11f0-9a5b-1e00900003a2"
network_id = "1eb73b50-1db5-42f5-8938-8592df101d61"
zone = "5ae50b9f-6280-4c4b-9551-ee48da867034"
expunge = true
root_disk_size = 10
details = {"cpuNumber" = "3","cpuSpeed"= "1000", "memory" = "3048"}
}
terraform apply
cloudstack_instance.VM1: Refreshing state... [id=95b67d96-8868-481f-a7c0-32d59a2d3a76]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# cloudstack_instance.VM1 will be updated in-place
~ resource "cloudstack_instance" "VM1" {
~ details = {
~ "cpuNumber" = "2" -> "3"
~ "memory" = "2048" -> "3048"
# (1 unchanged element hidden)
}
id = "95b67d96-8868-481f-a7c0-32d59a2d3a76"
name = "TERRAFORMVM2"
tags = {}
# (12 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
cloudstack_instance.VM1: Modifying... [id=95b67d96-8868-481f-a7c0-32d59a2d3a76]
╷
│ Error: Error updating the details for instance map[cpuNumber:3 cpuSpeed:1000 memory:3048]: CloudStack API error 530 (CSExceptionErrorCode: 4250): Failed to update VM, due to: Invalid cpu speed value, specify a value between 1 and 2147483647
│
│ with cloudstack_instance.VM1,
│ on main.tf line 10, in resource "cloudstack_instance" "VM1":
│ 10: resource "cloudstack_instance" "VM1" {
Cloudstack logs
2025-09-01 05:50:23,315 DEBUG [c.c.a.ApiServlet] (qtp253011924-22:[ctx-940a111d]) (logid:fc29aeaf) ===START=== 10.0.3.251 -- POST
apiKey=LIN6rqXuaJwMPfGYFh13qDwYz5VNNz1J2J6qIOWcd3oLQOq0WtD4CwRundBL6rzXToa3lQOC_vKjI3nkHtiD8Q
command=updateVirtualMachine
details[0].cpuNumber=3
details[1].cpuSpeed=1000
details[2].memory=3048
id=95b67d96-8868-481f-a7c0-32d59a2d3a76
response=json
signature=G/HlmiZa5S4h8cPhLhm/nR0DlGM=
2025-09-01 05:50:23,318 DEBUG [c.c.a.ApiServer] (qtp253011924-22:[ctx-940a111d, ctx-66aac16e]) (logid:fc29aeaf) CIDRs from which account 'Account [{"accountName":"admin","id":2,"uuid":"41afc720-7731-11f0-9a5b-1e00900003a2"}]' is allowed to perform API calls: 0.0.0.0/0,::/0
2025-09-01 05:50:23,319 INFO [o.a.c.a.DynamicRoleBasedAPIAccessChecker] (qtp253011924-22:[ctx-940a111d, ctx-66aac16e]) (logid:fc29aeaf) Account for user id 2f9808c5-4982-4429-a60b-9a976e8e6d2c is Root Admin or Domain Admin, all APIs are allowed.
2025-09-01 05:50:23,320 DEBUG [o.a.c.a.StaticRoleBasedAPIAccessChecker] (qtp253011924-22:[ctx-940a111d, ctx-66aac16e]) (logid:fc29aeaf) RoleService is enabled. We will use it instead of StaticRoleBasedAPIAccessChecker.
2025-09-01 05:50:23,320 DEBUG [o.a.c.r.ApiRateLimitServiceImpl] (qtp253011924-22:[ctx-940a111d, ctx-66aac16e]) (logid:fc29aeaf) API rate limiting is disabled. We will not use ApiRateLimitService.
2025-09-01 05:50:23,325 DEBUG [c.c.u.AccountManagerImpl] (qtp253011924-22:[ctx-940a111d, ctx-66aac16e, ctx-6cf41393]) (logid:fc29aeaf) Account [Account [{"accountName":"admin","id":2,"uuid":"c71ad71f-3ed4-41e7-87c5-4ef626a49d1b"}]] has access to resource.
2025-09-01 05:50:23,329 DEBUG [o.a.c.u.UserDataManagerImpl] (qtp253011924-22:[ctx-940a111d, ctx-66aac16e, ctx-6cf41393]) (logid:fc29aeaf) Null/empty base64 encoded user data set
2025-09-01 05:50:23,342 ERROR [c.c.a.ApiServer] (qtp253011924-22:[ctx-940a111d, ctx-66aac16e, ctx-6cf41393]) (logid:fc29aeaf) unhandled exception executing api command: [Ljava.lang.String;@1a3f106b com.cloud.utils.exception.CloudRuntimeException: Failed to update VM, due to: Invalid cpu speed value, specify a value between 1 and 2147483647
at org.apache.cloudstack.api.command.user.vm.UpdateVMCmd.execute(UpdateVMCmd.java:308)
at com.cloud.api.ApiDispatcher.dispatch(ApiDispatcher.java:173)
at com.cloud.api.ApiServer.queueCommand(ApiServer.java:854)
at com.cloud.api.ApiServer.handleRequest(ApiServer.java:668)
at com.cloud.api.ApiServlet.processRequestInContext(ApiServlet.java:416)
at com.cloud.api.ApiServlet$1.run(ApiServlet.java:193)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
at com.cloud.api.ApiServlet.processRequest(ApiServlet.java:190)
at com.cloud.api.ApiServlet.doPost(ApiServlet.java:149)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:665)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
at org.eclipse.jetty.servlet.ServletHolder$NotAsync.service(ServletHolder.java:1450)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:554)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:505)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:772)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.Server.handle(Server.java:516)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: com.cloud.exception.InvalidParameterValueException: Invalid cpu speed value, specify a value between 1 and 2147483647
at com.cloud.vm.UserVmManagerImpl.validateCustomParameters(UserVmManagerImpl.java:1341)
at com.cloud.vm.UserVmManagerImpl.verifyVmLimits(UserVmManagerImpl.java:2799)
at com.cloud.vm.UserVmManagerImpl.updateVirtualMachine(UserVmManagerImpl.java:2969)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.apache.cloudstack.network.contrail.management.EventUtils$EventInterceptor.invoke(EventUtils.java:109)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
at com.cloud.event.ActionEventInterceptor.invoke(ActionEventInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
at jdk.proxy3/jdk.proxy3.$Proxy219.updateVirtualMachine(Unknown Source)
at org.apache.cloudstack.api.command.user.vm.UpdateVMCmd.execute(UpdateVMCmd.java:306)
... 47 more
2025-09-01 05:50:23,344 DEBUG [c.c.a.ApiServlet] (qtp253011924-22:[ctx-940a111d, ctx-66aac16e, ctx-6cf41393]) (logid:fc29aeaf) ===END=== 10.0.3.251 -- POST
apiKey=LIN6rqXuaJwMPfGYFh13qDwYz5VNNz1J2J6qIOWcd3oLQOq0WtD4CwRundBL6rzXToa3lQOC_vKjI3nkHtiD8Q
command=updateVirtualMachine
details[0].cpuNumber=3
details[1].cpuSpeed=1000
details[2].memory=3048
id=95b67d96-8868-481f-a7c0-32d59a2d3a76
response=json
signature=G/HlmiZa5S4h8cPhLhm/nR0DlGM=
Ideally the API should be
update virtualmachine id=788cf2f4-c77b-4b54-abeb-26381a1592c0 details[0].cpuNumber=3 details[0].cpuSpeed=1000 details[0].memory=3048
But if performed via terraform the details count is changing
I checked this and this is due to a bug in cloudstack-go SDK. |
@kiranchavala I have created a fix in cloudstack-go SDK here: apache/cloudstack-go#118 |
Fixes #58 #148