Skip to content

fix: apply host updates and convert the host_tags list - #345

Open
nagaboinaramgopal wants to merge 1 commit into
apache:mainfrom
nagaboinaramgopal:fix/host-update-missing-call
Open

fix: apply host updates and convert the host_tags list#345
nagaboinaramgopal wants to merge 1 commit into
apache:mainfrom
nagaboinaramgopal:fix/host-update-missing-call

Conversation

@nagaboinaramgopal

@nagaboinaramgopal nagaboinaramgopal commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Description

Two problems with the cloudstack_host resource.

resourceCloudStackHostUpdate built its UpdateHostParams and set allocation_state and host_tags on it, but never called UpdateHost, so updating either field silently did nothing.

host_tags is a schema.TypeList, so the SDK returns []interface{}, but both create and update asserted host_tags.([]string), which panics with interface conversion: interface {} is []interface {}, not []string when host_tags is set. Neither field is ForceNew, so the update path is reachable.

Fixed by calling UpdateHost when a tracked field actually changed, and by converting the list to []string on both the create and update paths.

Testing

Two unit tests, no live CloudStack:

go test ./cloudstack/ -run 'TestHostCreateHostTagsDoesNotPanic|TestHostUpdateCallsUpdateHost'

TestHostCreateHostTagsDoesNotPanic creates a host with host_tags set; it panics against the current code and gets past the conversion with the fix. TestHostUpdateCallsUpdateHost runs 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.

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
nagaboinaramgopal force-pushed the fix/host-update-missing-call branch from 1b5ae0b to 0328f62 Compare September 7, 2026 19:31
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