Skip to content

fix: make network offering update work (set the id) and read back correctly - #339

Open
nagaboinaramgopal wants to merge 1 commit into
apache:mainfrom
nagaboinaramgopal:fix/network-offering-update-read
Open

fix: make network offering update work (set the id) and read back correctly#339
nagaboinaramgopal wants to merge 1 commit into
apache:mainfrom
nagaboinaramgopal:fix/network-offering-update-read

Conversation

@nagaboinaramgopal

Copy link
Copy Markdown

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.

…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>
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 this pull request may close these issues.

1 participant