Repository navigation
fix(load_balancers): forward admin_state_up, default_pool_id and delete_default_pool in *_and_poll helpers - #68
Closed
JingHao-Leon wants to merge 2 commits into
Conversation
…arams The hand-written *_and_poll helpers for load balancer listeners and pools do not accept parameters that the generated methods they wrap support (admin_state_up, default_pool_id, delete_default_pool), so callers get a TypeError instead of being able to reach those API fields. Adds regression coverage that calls each helper with the parameter and asserts it reaches the API request.
…te_default_pool in *_and_poll helpers The hand-written load balancer *_and_poll helpers re-declare the parameter list of the generated method they wrap, and those re-declarations had dropped parameters the generated methods support: - listeners.create_and_poll: default_pool_id - listeners.update_and_poll: admin_state_up - listeners.delete_and_poll: delete_default_pool - pools.update_and_poll: admin_state_up Passing any of them raised TypeError before a request was made, so those API fields could not be used through the convenience methods. Declare and forward them in both the sync and async helpers. Fixes G-Core#67
Contributor
|
Thanks @JingHao-Leon, the fix is correct and the regression tests are very useful. This repository is published from our private staging repository, and changes only flow one way at this time. So we've brought your commits into a staging repository PR unchanged, with you as their author. It'll be in the next release. We are also adding a test that fails CI whenever an |
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.
What broke
The hand-written
*_and_pollconvenience methods for load balancer listeners and pools did not accept some of the parameters that the generated API methods support, so those API fields could not be used through the convenience methods:cloud.load_balancers.listeners.create_and_polldefault_pool_idcloud.load_balancers.listeners.update_and_polladmin_state_upcloud.load_balancers.listeners.delete_and_polldelete_default_poolcloud.load_balancers.pools.update_and_polladmin_state_upPassing any of them raised a
TypeErrorbefore a request was made:admin_state_upis the documented way to enable/disable a listener or a pool ("When set to false, the resource is disabled and will not process traffic"), so there was no way to turn a listener or pool off throughupdate_and_poll.The
AsyncGcorevariants of the same four methods were affected identically.Root cause
The
*_and_pollhelpers are hand-written mixins, not codegen output — the file headers state: "Custom code. This file is not generated and is preserved across codegen runs." Each helper re-declares the parameter list of the generated method it wraps, and those re-declarations had drifted from the generated signatures:src/gcore/resources/cloud/load_balancers/listeners_custom.py:34—create_and_polldeclared nodefault_pool_id, while the generatedcreatedeclares it atsrc/gcore/resources/cloud/load_balancers/listeners.py:73.src/gcore/resources/cloud/load_balancers/listeners_custom.py:143—update_and_polldeclared noadmin_state_up, while the generatedupdatedeclares it atsrc/gcore/resources/cloud/load_balancers/listeners.py:175.src/gcore/resources/cloud/load_balancers/listeners_custom.py:107—delete_and_polldeclared nodelete_default_pool, while the generateddeletedeclares it atsrc/gcore/resources/cloud/load_balancers/listeners.py:347.src/gcore/resources/cloud/load_balancers/pools/pools_custom.py:138—update_and_polldeclared noadmin_state_up, while the generatedupdatedeclares it atsrc/gcore/resources/cloud/load_balancers/pools/pools.py:192.Because each helper forwards only the parameters it declares, the field never reached the API.
The change
Declare the missing parameters in the helpers and forward them to the generated method, in both the sync and the async mixin. The new parameters are keyword-only and default to
omit, so existing calls are unaffected.src/gcore/resources/cloud/load_balancers/listeners_custom.py—default_pool_idoncreate_and_poll,admin_state_uponupdate_and_poll,delete_default_poolondelete_and_poll(sync + async).src/gcore/resources/cloud/load_balancers/pools/pools_custom.py—admin_state_uponupdate_and_poll(sync + async).How to verify
The new regression test in
tests/api_resources/cloud/test_and_poll_custom.pycalls each of the four helpers with the parameter and asserts that it reaches the API request (in the JSON body, or in the query string fordelete_default_pool).Before the fix:
After the fix:
The whole hand-written
*_and_polltest suite:The rest of the unit suite is unchanged compared to the base commit — the same 4 failures before and after, and they are the pre-existing ones that need the mock API server on
127.0.0.1:4010(httpx.ConnectError: [Errno 61] Connection refused):Lint and types:
The 10 mypy errors are pre-existing and unrelated to this change — the identical count is reported on the base commit
75c6b55f(missing optionalhttpx_aiohttpextra,noxstubs, and pydantic signature differences in this environment).CI
gh pr checksreports no results for this branch. The workflow runs exist but are held at the upstream approval gate: 5 runs were created for the head SHA016b3d22(4 distinct workflows —CItwice,Fossa,Release Doctor,Trunk sync lock), all with conclusionaction_requiredand 0 jobs executed, i.e. they are waiting for a maintainer to approve running them.So there is no upstream test result for this branch yet, and the verification numbers above are from local runs.
Fixes #67
This change was prepared with the assistance of an AI coding agent.