Skip to content

Conversation

@stephenfin
Copy link
Contributor

@stephenfin stephenfin commented Oct 9, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Avoided emitting invalid network/subnet configurations when input fields are empty.
    • Ports now require either a network reference or fixedIPs; clearer error messaging when both are missing.
    • Preserved tag handling and only attach fixed IPs when subnet data exists.
  • Stability

    • Added guarded checks to prevent empty network/subnet translations and reduce misconfiguration risk.
  • Tests

    • Updated fuzz tests to cover subnet-present and empty-filter network scenarios.

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Oct 9, 2025
@openshift-ci-robot
Copy link

@stephenfin: This pull request references Jira Issue OCPBUGS-62892, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @sunzhaohua2

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

MAPI↔CAPO OpenStack conversion logic was tightened: network, filter, subnet, fixed-IP, and port-tag fields are built only when corresponding input exists; nil checks and guarded assignments were added in both conversion directions; fuzz test network case now uses an empty UUID with a Filter and a SubnetParam.

Changes

Cohort / File(s) Summary of Changes
MAPI → CAPO conversion
pkg/conversion/mapi2capi/openstack.go
- Introduced local capoNetwork, capoSubnet, capoPort, and capoFixedIP and populate them only when input fields exist
- Assign capoNetwork.ID when MAPI network UUID exists
- Populate capoNetwork.Filter (and compute ProjectID) only if MAPI Filter is non-empty
- For subnet-only paths, avoid emitting network config; build capoPort.Tags, per-subnet capoSubnet, and conditional capoFixedIP only when relevant fields exist
- Ensure final PortOpts uses capoFixedIPs and capoNetwork only when built
CAPO → MAPI conversion
pkg/conversion/capi2mapi/openstack.go
- Added nil check on capoPort.Network and guarded handling of Network.ID vs Network.Filter (map UUID or populate Filter fields)
- If capoPort.Network is nil and no FixedIPs, return an error requiring network or subnet reference ("Either a network or fixedIPs must be specified on a port")
- Assign port tags to MAPI subnet (PortTags) and populate subnet Filter fully when present; otherwise use UUID-based SubnetParam
- Broadened condition to convert network when network has ID/filter or when FixedIPs reference a subnet
Fuzz tests
pkg/conversion/mapi2capi/openstack_fuzz_test.go
- Modified fuzz case 0: set network.UUID to empty string, initialize network.Filter as an empty Filter, and add Subnets containing a generated SubnetParam (previously set UUID only)

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant M2C as convertMAPONetworksToCAPO
  participant Builder as CAPO Port Builder

  Caller->>M2C: convert MAPI network(s)
  activate M2C

  M2C->>M2C: iterate networks
  alt network.UUID present
    M2C->>Builder: set capoNetwork.ID
  end
  alt network.Filter non-empty
    M2C->>M2C: compute ProjectID (if needed)
    M2C->>Builder: set capoNetwork.Filter
  else Filter empty
    note right of M2C: skip Filter population
  end

  alt no network but subnets present
    M2C->>M2C: for each subnet build capoSubnet and capoFixedIP only if fields exist
    M2C->>Builder: append capoFixedIP(s) and Tags
  else network present
    M2C->>Builder: attach capoNetwork and capoFixedIPs (if any)
  end

  M2C-->>Caller: CAPO Port/Network objects
  deactivate M2C
Loading
sequenceDiagram
  autonumber
  participant Caller
  participant C2M as convertCAPOPortOptsToMAPO
  participant Builder as MAPI Network Builder

  Caller->>C2M: convert CAPO PortOpts
  activate C2M

  C2M->>C2M: inspect capoPort.Network
  alt capoPort.Network != nil
    opt Network.ID
      C2M->>Builder: set mapoNetwork.UUID from ID
    end
    opt Network.Filter
      C2M->>Builder: set mapoNetwork.Filter (tags, not-tags, projectID...)
    end
    alt neither ID nor Filter
      C2M->>Caller: record error "A network must be referenced by a UUID or filter"
    end
  else capoPort.Network == nil
    alt capoPort.FixedIPs present
      C2M->>C2M: set PortTags, build mapoSubnet(s) from FixedIPs (UUID or Filter)
      C2M->>Builder: attach subnet params
    else
      C2M->>Caller: record error "Either a network or fixedIPs must be specified on a port"
    end
  end

  C2M-->>Caller: MAPI network/port spec or errors
  deactivate C2M
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Pay special attention to: convertMAPONetworksToCAPO network/subnet conditional branches, correct preservation and conditional population of Tag/NotTag fields, and the new nil-check/error paths in convertCAPOPortOptsToMAPO.
  • Verify fuzz test change aligns with conversion expectations (empty UUID + Filter + SubnetParam).

Poem

I twitch my whiskers, check each gate,
Only when fields exist do I populate.
Nets and subs now hop in place,
No phantom IDs left to chase.
A tidy rabbit guards each space. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "OCPBUGS-62892: openstack: Handle empty MAPO network subnets" directly reflects the main objective and changes in the PR. The raw summary confirms that the core changes introduce guarded logic to skip network/subnet configurations when inputs are empty, only emit configurations when corresponding input data is provided, and ensure subnets without identifiers are handled with warnings. The title is concise, specific, and clearly identifies the primary change from the changeset without being vague or misleading.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 6004d19 and 1658dbd.

📒 Files selected for processing (3)
  • pkg/conversion/capi2mapi/openstack.go (4 hunks)
  • pkg/conversion/mapi2capi/openstack.go (6 hunks)
  • pkg/conversion/mapi2capi/openstack_fuzz_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/conversion/mapi2capi/openstack_fuzz_test.go

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci bot requested a review from sunzhaohua2 October 9, 2025 12:12
@openshift-ci-robot
Copy link

@stephenfin: This pull request references Jira Issue OCPBUGS-62892, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @sunzhaohua2

In response to this:

Summary by CodeRabbit

  • Bug Fixes

  • Subnets without identifiers are now skipped with a clear warning, preventing invalid network configurations.

  • Corrected tag application to occur per subnet after ID resolution, ensuring tags are only applied to valid subnets.

  • Reduced risk of creating incorrect OpenStack port configurations from incomplete subnet data.

  • Tests

  • Added coverage to verify warnings and behavior when subnets lack identifiers.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from mdbooth and nrb October 9, 2025 12:16
@damdo
Copy link
Member

damdo commented Oct 9, 2025

/assign @mdbooth

@damdo
Copy link
Member

damdo commented Oct 9, 2025

/test ?

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 9, 2025

@damdo: The following commands are available to trigger required jobs:

/test build
/test e2e-aws-capi-techpreview
/test e2e-aws-ovn
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-aws-ovn-techpreview
/test e2e-aws-ovn-techpreview-upgrade
/test e2e-azure-capi-techpreview
/test e2e-azure-ovn-techpreview-upgrade
/test e2e-gcp-capi-techpreview
/test e2e-gcp-ovn-techpreview
/test e2e-openstack-capi-techpreview
/test e2e-openstack-ovn-techpreview
/test e2e-vsphere-capi-techpreview
/test images
/test lint
/test okd-scos-images
/test unit
/test vendor
/test verify-deps

The following commands are available to trigger optional jobs:

/test e2e-azure-ovn-techpreview
/test e2e-metal3-capi-techpreview
/test okd-scos-e2e-aws-ovn
/test regression-clusterinfra-aws-ipi-techpreview-capi

Use /test all to run the following jobs that were automatically triggered:

pull-ci-openshift-cluster-capi-operator-main-build
pull-ci-openshift-cluster-capi-operator-main-images
pull-ci-openshift-cluster-capi-operator-main-lint
pull-ci-openshift-cluster-capi-operator-main-okd-scos-e2e-aws-ovn
pull-ci-openshift-cluster-capi-operator-main-okd-scos-images
pull-ci-openshift-cluster-capi-operator-main-unit
pull-ci-openshift-cluster-capi-operator-main-vendor
pull-ci-openshift-cluster-capi-operator-main-verify-deps

In response to this:

/test ?

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@damdo
Copy link
Member

damdo commented Oct 9, 2025

/test e2e-openstack-capi-techpreview

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 9, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from mdbooth. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

@mdbooth mdbooth left a comment

Choose a reason for hiding this comment

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

I think this fix is good. I think we also need need to fix subnetid if we want the test to pass, though.

@stephenfin stephenfin force-pushed the OCPBUGS-62892 branch 2 times, most recently from c8b86ab to 6004d19 Compare October 13, 2025 13:42
@stephenfin
Copy link
Contributor Author

/test e2e-openstack-capi-techpreview

@damdo
Copy link
Member

damdo commented Oct 13, 2025

@stephenfin @mdbooth It looks like E2Es passed on ci/prow/e2e-openstack-capi-techpreview but the overall job failed due to a gather step failure (which might be recurrent and worth fixing, although not in this PR :) )

@mdbooth if you are happy with the latest changes I think we should be ok overriding and merging.

@stephenfin
Copy link
Contributor Author

@stephenfin @mdbooth It looks like E2Es passed on ci/prow/e2e-openstack-capi-techpreview but the overall job failed due to a gather step failure (which might be recurrent and worth fixing, although not in this PR :) )

Ah, yes, we fixed that this morning openshift/release#70212. This job must have started before that patch merged. It's merged now though so let's re-run.

/test e2e-openstack-capi-techpreview

Copy link
Contributor

@mdbooth mdbooth left a comment

Choose a reason for hiding this comment

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

If you have time I still think there's a bunch of cleanup to do here. In particular I think this change highlights a latent panic which ideally we would fix.

However, given that it fixes an immediate problem I wouldn't want to hold it up for the issues here. Please consider having somebody on the team follow up, though.

/lgtm


// convert .Subnets
if networkID == "" && (mapoNetwork.Filter == mapiv1alpha1.Filter{}) { //nolint:nestif
if (capoNetwork == openstackv1.NetworkParam{}) { //nolint:nestif
Copy link
Contributor

Choose a reason for hiding this comment

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

Code structure observation. We have:

capoNetwork := switch {
  case mapoNetwork.UUID != "":
    addCAPOSubnets(capoNetwork{ID = &mapoNetwork.UUID}, ...)

  case mapoNetwork.Filter != nil:
    addCAPOSubnets(capoNetworkFromFilter(), ...)

  default:
    capoNetworkFromSubnets() (this if statement, which is the default/else of the above)
}

addCAPOSubnets() is the else branch starting line 483 below.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 14, 2025
@openshift-ci-robot
Copy link

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-capi-techpreview
/test e2e-aws-ovn
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-aws-ovn-techpreview
/test e2e-aws-ovn-techpreview-upgrade
/test e2e-azure-capi-techpreview
/test e2e-azure-ovn-techpreview
/test e2e-azure-ovn-techpreview-upgrade
/test e2e-gcp-capi-techpreview
/test e2e-gcp-ovn-techpreview
/test e2e-metal3-capi-techpreview
/test e2e-openstack-capi-techpreview
/test e2e-openstack-ovn-techpreview
/test e2e-vsphere-capi-techpreview
/test regression-clusterinfra-aws-ipi-techpreview-capi

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 14, 2025

@stephenfin: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-ovn-techpreview 6004d19 link true /test e2e-aws-ovn-techpreview
ci/prow/e2e-openstack-ovn-techpreview 6004d19 link true /test e2e-openstack-ovn-techpreview

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@damdo
Copy link
Member

damdo commented Oct 24, 2025

Hey @stephenfin what's the plan for this one? TY

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 30, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 30, 2025

New changes are detected. LGTM label has been removed.

@openshift-ci-robot
Copy link

@stephenfin: This pull request references Jira Issue OCPBUGS-62892, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request.

In response to this:

Summary by CodeRabbit

  • Bug Fixes

  • Avoided emitting invalid network/subnet configurations when input fields are empty.

  • Ports now require either a network reference or fixedIPs; clearer error messaging when both are missing.

  • Preserved tag handling and only attach fixed IPs when subnet data exists.

  • Stability

  • Added guarded checks to prevent empty network/subnet translations and reduce misconfiguration risk.

  • Tests

  • Updated fuzz tests to cover subnet-present and empty-filter network scenarios.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@stephenfin
Copy link
Contributor Author

/test e2e-openstack-capi-techpreview

@stephenfin
Copy link
Contributor Author

Hey @stephenfin what's the plan for this one? TY

Sorry for the delay. I've addressed all bar one of @mdbooth's comments now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants