You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by "nagaboinaramgopal (via GitHub)" <gi...@apache.org> on 2026/09/02 19:47:15 UTC

[PR] fix: make network offering update work (set the id) and read back correctly [cloudstack-terraform-provider]

nagaboinaramgopal opened a new pull request, #339:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/339

   ### Description
   
   `resourceCloudStackNetworkOfferingUpdate` was broken in two ways, and updating a `cloudstack_network_offering` failed outright:
   
   1. Each `UpdateNetworkOffering` call built its params with `NewUpdateNetworkOfferingParams()` but never set the offering id, so every update (name, display_text, max_connections, domain_id) failed with:
   
           CloudStack API error 530 (CSExceptionErrorCode: 9999): Cannot invoke
           "java.lang.Long.longValue()" because "id" is null
   
      Fixed by setting the id on each params struct.
   
   2. After updating, the function returned `resourceCloudStackInstanceRead`, the read function for the `cloudstack_instance` resource, which looks up a VM by the network offering id and corrupts the resource state. Fixed to return `resourceCloudStackNetworkOfferingRead`, matching the Create and Read paths.
   
   ### Testing
   
   Added an acceptance test `TestAccCloudStackNetworkOffering_update` that creates a network offering and then updates its `display_text`. It fails before this change (the `id is null` API error) and passes after.
   
   Verified end to end against a live CloudStack advanced zone:
   
           TF_ACC=1 go test ./cloudstack/ -run TestAccCloudStackNetworkOffering_update
           --- PASS: TestAccCloudStackNetworkOffering_update
   
   `go build ./...`, `go vet ./...`, and the unit suite (`go test ./cloudstack/`) also pass.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: make network offering update work (set the id) and read back correctly [cloudstack-terraform-provider]

Posted by "sureshanaparti (via GitHub)" <gi...@apache.org>.
sureshanaparti merged PR #339:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/339


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: make network offering update work (set the id) and read back correctly [cloudstack-terraform-provider]

Posted by "sudo87 (via GitHub)" <gi...@apache.org>.
sudo87 commented on PR #339:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/339#issuecomment-5521158838

   @nagaboinaramgopal please address the copilot's comments


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: make network offering update work (set the id) and read back correctly [cloudstack-terraform-provider]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #339:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/339#discussion_r3921418214


##########
cloudstack/resource_cloudstack_network_offering.go:
##########
@@ -316,6 +325,9 @@ func resourceCloudStackNetworkOfferingUpdate(d *schema.ResourceData, meta interf
 		// Create a new parameter struct
 		p := cs.NetworkOffering.NewUpdateNetworkOfferingParams()
 
+		// Target this network offering
+		p.SetId(d.Id())
+
 		// Set the new domain id
 		p.SetDomainid(d.Get("domain_id").(string))
 

Review Comment:
   The domain_id update block sets Domainid, but the subsequent inline comment / error message refers to "traffic type", which is misleading when troubleshooting failures in this update path.



##########
cloudstack/resource_cloudstack_network_offering_test.go:
##########
@@ -0,0 +1,64 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package cloudstack
+
+import (
+	"fmt"
+	"testing"
+
+	"github.com/hashicorp/terraform-plugin-testing/helper/resource"
+)

Review Comment:
   This acceptance test will need CloudStack client and terraform state imports once it adds remote existence / destroy verification (consistent with other acceptance tests in this repo).
   
   This issue also appears in the following locations of the same file:
   - line 30
   - line 55



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org