fix: apply host updates and convert the host_tags list - #345
Open
nagaboinaramgopal wants to merge 1 commit into
Open
fix: apply host updates and convert the host_tags list#345nagaboinaramgopal wants to merge 1 commit into
nagaboinaramgopal wants to merge 1 commit into
Conversation
resourceCloudStackHostUpdate built its UpdateHostParams and set allocation_state and host_tags but never called UpdateHost, so host updates did nothing. host_tags is a schema.TypeList, so the SDK returns []interface{}, but create and update asserted host_tags.([]string), which panics when host_tags is set. Call UpdateHost when something changed, and convert the list to []string on both paths. Tests cover the host_tags conversion (no panic on create) and that an update actually issues an UpdateHost request.
nagaboinaramgopal
force-pushed
the
fix/host-update-missing-call
branch
from
September 7, 2026 19:31
1b5ae0b to
0328f62
Compare
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
Two problems with the
cloudstack_hostresource.resourceCloudStackHostUpdatebuilt itsUpdateHostParamsand setallocation_stateandhost_tagson it, but never calledUpdateHost, so updating either field silently did nothing.host_tagsis aschema.TypeList, so the SDK returns[]interface{}, but both create and update assertedhost_tags.([]string), which panics withinterface conversion: interface {} is []interface {}, not []stringwhen host_tags is set. Neither field is ForceNew, so the update path is reachable.Fixed by calling
UpdateHostwhen a tracked field actually changed, and by converting the list to[]stringon both the create and update paths.Testing
Two unit tests, no live CloudStack:
TestHostCreateHostTagsDoesNotPaniccreates a host with host_tags set; it panics against the current code and gets past the conversion with the fix.TestHostUpdateCallsUpdateHostruns an update with a changed field and asserts the returned error comes from the UpdateHost request; without the fix the update never calls UpdateHost and falls through to the read, so the test fails.