Skip to content

Implement Placement allocationcandidates - #3701

Merged
mandre merged 2 commits into
gophercloud:mainfrom
Etua:implement-allocation-candidate-list
Apr 10, 2026
Merged

mandre merged 2 commits into
gophercloud:mainfrom
Etua:implement-allocation-candidate-list

Conversation

@Etua

@Etua Etua commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Related #526

API reference:
https://docs.openstack.org/api-ref/placement/#list-allocation-candidates

Code reference:
https://opendev.org/openstack/placement/src/branch/stable/2026.1/placement/handlers/allocation_candidate.py#L256-L304

I didn't create separate microversions for every change when an argument could be repeated starting from … (change from string to []string), since one can create a single-element slice, so the request can still be expressed using this structure for any microversion 1.12+ unlike the array to map transition at 1.11 to 1.12. Having separate microversions for every such change would balloon the number of structures and related tests to 5+.

I also made the newer request structure the default and put the one from the first 2 microversions (1.10-1.11) in microversions.go, as the old version was made in 2018 and there's a low chance one would default to the original shape, which is very limited in expressiveness of request and response.

Please let me know if any of these decisions would prevent this patch from being merged.

@github-actions github-actions Bot added edit:placement This PR updates placement code semver:minor Backwards-compatible change backport-v2 This PR will be backported to v2 labels Apr 8, 2026
@coveralls

coveralls commented Apr 8, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 64.0% (+0.03%) from 63.973% — Etua:implement-allocation-candidate-list into gophercloud:main

@mandre mandre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice work, the design choice make sense to me, so no objection to that. We should perhaps fix the IsEmpty() method that will crash with the 1.10 microversion.

Comment thread openstack/placement/v1/allocationcandidates/requests.go
Comment thread openstack/placement/v1/allocationcandidates/results.go Outdated
Full deserialisation could crash on older structure defined for 1.10.

Co-authored-by: Martin André <[email protected]>
Signed-off-by: Dominik Danelski <[email protected]>
@mandre
mandre added this pull request to the merge queue Apr 10, 2026
Merged via the queue into gophercloud:main with commit 7e35969 Apr 10, 2026
64 checks passed
@Etua
Etua deleted the implement-allocation-candidate-list branch April 10, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v2 This PR will be backported to v2 edit:placement This PR updates placement code semver:minor Backwards-compatible change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants