Skip to content

fix(ibm): respect configured zone for custom VPC subnets - #528

Open
Gisaldjo wants to merge 1 commit into
canonical:mainfrom
Gisaldjo:feat/filter-subnets-by-zone
Open

fix(ibm): respect configured zone for custom VPC subnets#528
Gisaldjo wants to merge 1 commit into
canonical:mainfrom
Gisaldjo:feat/filter-subnets-by-zone

Conversation

@Gisaldjo

@Gisaldjo Gisaldjo commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Select a subnet in the explicit or configured zone, creating one there if needed. Preserve first-subnet selection when no zone is provided, and creation in -1 when the VPC has no subnets.

Description

Custom VPC subnet discovery currently selects the first subnet, even
when an explicit or configured zone is provided. In a multi-zone VPC,
this can select a subnet in a different zone from the requested
instance, causing instance creation to fail.

Select a subnet in the requested zone instead, creating one there if
none exists.

Preserve existing behavior when no zone is provided: select the first
subnet, or create one in <region>-1 if the VPC has no subnets.

Additional Context and Relevant Issues

New zone-specific subnets include the zone in their names to avoid
collisions with existing subnets. Very long VPC names may exceed IBM's
subnet-name limit; name truncation is not addressed here.

Test Steps

  • All 34 IBM unit tests passed.
  • Ruff lint and format checks passed.
  • Scoped mypy, Python 3.10 tests, and the docs build passed before the
    final compatibility test was added.
  • Live verification passed for:
    • Configured-zone selection when the first subnet is in another zone.
    • Instance launch and SSH access.
    • Omitted-zone first-subnet selection.
    • Empty-VPC subnet creation in -1 when zone is omitted.
    • Creation in the configured zone when no matching subnet exists,
      preserving the existing subnet.
  • Temporary live-test resources were deleted.
  • Ran tox: Ruff passed and all 327 unit tests passed on Python 3.8.
    Mypy failed in unchanged Azure code at
    pycloudlib/azure/instance.py:293 with a begin_create_or_update
    overload mismatch.

Select a subnet in the explicit or configured zone, creating one
there if needed. Preserve first-subnet selection when no zone is
provided, and creation in <region>-1 when the VPC has no subnets.
@Gisaldjo
Gisaldjo marked this pull request as ready for review September 9, 2026 11:45
@Gisaldjo
Gisaldjo requested a review from blackboxsw September 9, 2026 11:47
),
)
if subnet is None:
raise IBMException(f"No subnet associated to vpc found: {vpc_id}")

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.

Can we also print zone in the error message, if zone is not None? It will be easier for debugging.

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