Resolve Code Engine subnet pool id from a configured name - #2455
Open
Elena Peña Tapia (ElePT) wants to merge 1 commit into
Open
Resolve Code Engine subnet pool id from a configured name#2455Elena Peña Tapia (ElePT) wants to merge 1 commit into
Elena Peña Tapia (ElePT) wants to merge 1 commit into
Conversation
A Code Engine project can now be configured with a subnet pool name (subnet_pool_name) instead of its id. The IBM Cloud console shows a pool's name readily but not its id, so requiring the id added friction to every project onboarding. When only a name is configured, the gateway resolves it to the id against the Code Engine API on the first job submission for that project and caches the id back onto the CodeEngineProject row, so later jobs reuse it without another lookup. Supplying subnet_pool_id directly still works and skips resolution. Because a pool name is not guaranteed unique within a project (the CE API only advises uniqueness; pools are identified by id), a name matching more than one pool fails the submission with an error naming the matching ids rather than guessing which pool to place the fleet on. - Vendor SubnetPoolsApi.list_subnet_pools plus the V2SubnetPool(List) models into the gateway ce_client (only list is needed). - Add FleetHandler.resolve_subnet_pool_id, which pages through the project's pools and fails loud on zero or multiple name matches. - Resolve and cache in FleetsRunner.submit(); make subnet_pool_id nullable and add subnet_pool_name (migration 0062). - sync_ce_project accepts either field, requires at least one, and invalidates a cached id only when the configured name changes (so re-sync does not wipe the cache every boot).
Elena Peña Tapia (ElePT)
marked this pull request as ready for review
September 4, 2026 07:49
Marcelo Carneiro do Amaral (marceloamaral)
left a comment
Contributor
There was a problem hiding this comment.
Looks like a good feature to have as we discussed it before!
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.
Warning
Draft — pending confirmation in staging. The name→id lookup calls
GET /projects/{id}/subnet_pools, which is present in the swagger SDK and modelled here, but I have not yet confirmed the target CE region actually serves it at the deployed API version. Before this leaves draft, runlist_subnet_poolsagainst a staging project (equivalentlyibmcloud ce connectivity subnetpool list, the same endpoint) and confirm it returnsid+name. Everything below is verified by unit tests and static checks only.Summary
A Code Engine project can now be configured with a subnet pool name (
subnet_pool_name) instead of its id. The IBM Cloud console shows a pool's name readily but not its id, so requiring the id added friction to every project onboarding.When only a name is configured, the gateway resolves it to the id against the CE API on the first job submission for that project and caches the id back onto the
CodeEngineProjectrow, so later jobs reuse it without another lookup. Supplyingsubnet_pool_iddirectly still works and skips resolution.Because a pool name is not guaranteed unique within a project (the CE API only advises uniqueness; pools are identified by id), a name matching more than one pool fails the submission with an error naming the matching ids rather than guessing which pool to place the fleet on.
Changes
SubnetPoolsApi.list_subnet_pools+ theV2SubnetPool/V2SubnetPoolListmodels into the gatewayce_client(onlylistis needed; reuses the already-vendored pagination models).FleetHandler.resolve_subnet_pool_id— pages through the project's pools, matches by exact name, raises on zero or multiple matches.FleetsRunner.submit()— resolve-and-cache via a new_ensure_subnet_pool_id;subnet_pool_idmade nullable andsubnet_pool_nameadded (migration0062).sync_ce_project— accepts either field, requires at least one, and invalidates a cached id only when the configured name changes (so re-sync doesn't wipe the cache every boot, givenupdate_or_createoverwrites all defaults).Verification
158/158tests pass acrosstest_fleets_runner,fleets/handler tests, andtest_sync_ce_project(14 new). Covers: id-in-config skips resolution; name-only resolves once + caches; reuse without a second call; ambiguity/not-found raise; pagination; sync accept/reject and rename-invalidation.makemigrations --checkclean ✅Out of scope (follow-up)
Resolving
project_name→project_idandresource_group_name→resource_group_id. They're not symmetric with subnet pool:project_idis the row's primary key needed before a CE client exists (no lazy-at-submit hook), andresource_group_idlives in a different service (Resource Manager). Both should share the fail-loud-on-ambiguity contract used here.