Skip to content

Resolve Code Engine subnet pool id from a configured name - #2455

Open
Elena Peña Tapia (ElePT) wants to merge 1 commit into
mainfrom
resolve-subnet-pool-by-name
Open

Resolve Code Engine subnet pool id from a configured name#2455
Elena Peña Tapia (ElePT) wants to merge 1 commit into
mainfrom
resolve-subnet-pool-by-name

Conversation

@ElePT

Copy link
Copy Markdown
Collaborator

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, run list_subnet_pools against a staging project (equivalently ibmcloud ce connectivity subnetpool list, the same endpoint) and confirm it returns id + 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 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.

Changes

  • Vendor SubnetPoolsApi.list_subnet_pools + the V2SubnetPool/V2SubnetPoolList models into the gateway ce_client (only list is 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_id made nullable and subnet_pool_name added (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 doesn't wipe the cache every boot, given update_or_create overwrites all defaults).

Verification

  • 158/158 tests pass across test_fleets_runner, fleets/ handler tests, and test_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.
  • black ✅ · pylint 10.00/10 ✅ · import-linter ✅ · makemigrations --check clean ✅
  • Not run: the live CE call (see warning above).

Out of scope (follow-up)

Resolving project_nameproject_id and resource_group_nameresource_group_id. They're not symmetric with subnet pool: project_id is the row's primary key needed before a CE client exists (no lazy-at-submit hook), and resource_group_id lives in a different service (Resource Manager). Both should share the fail-loud-on-ambiguity contract used here.

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).
@ElePT
Elena Peña Tapia (ElePT) marked this pull request as ready for review September 4, 2026 07:49
@ElePT
Elena Peña Tapia (ElePT) requested a review from a team as a code owner September 4, 2026 07:49

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.

Looks like a good feature to have as we discussed it before!

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.

2 participants