fix: make network offering update work (set the id) and read back correctly - #339
Open
nagaboinaramgopal wants to merge 1 commit into
Open
Conversation
…rectly resourceCloudStackNetworkOfferingUpdate was broken in two ways: 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 ... Cannot invoke java.lang.Long.longValue() because id is null". Set the id on each params struct. 2. After updating, it returned resourceCloudStackInstanceRead, the instance read function, which looks up a VM by the network offering id and corrupts state. Return resourceCloudStackNetworkOfferingRead instead. Adds an acceptance test that creates a network offering and updates its display_text; it fails before this change and passes after. Verified against a CloudStack advanced zone. Signed-off-by: Ramgopal Nagaboina <ramgopal.nagaboina.dev@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
resourceCloudStackNetworkOfferingUpdatewas broken in two ways, and updating acloudstack_network_offeringfailed outright:Each
UpdateNetworkOfferingcall built its params withNewUpdateNetworkOfferingParams()but never set the offering id, so every update (name, display_text, max_connections, domain_id) failed with:Fixed by setting the id on each params struct.
After updating, the function returned
resourceCloudStackInstanceRead, the read function for thecloudstack_instanceresource, which looks up a VM by the network offering id and corrupts the resource state. Fixed to returnresourceCloudStackNetworkOfferingRead, matching the Create and Read paths.Testing
Added an acceptance test
TestAccCloudStackNetworkOffering_updatethat creates a network offering and then updates itsdisplay_text. It fails before this change (theid is nullAPI error) and passes after.Verified end to end against a live CloudStack advanced zone:
go build ./...,go vet ./..., and the unit suite (go test ./cloudstack/) also pass.