Skip to content

OSASINFRA-4400: make openstack allowed address pairs configurable - #230

Open
danchild wants to merge 2 commits into
openshift:mainfrom
shiftstack:openstack-allowed-address-pairs
Open

OSASINFRA-4400: make openstack allowed address pairs configurable#230
danchild wants to merge 2 commits into
openshift:mainfrom
shiftstack:openstack-allowed-address-pairs

Conversation

@danchild

@danchild danchild commented Jul 15, 2026

Copy link
Copy Markdown
Member

Currently, the maxmium allowed address pairs per port configuration
is hardcoded to OpenStack's default of 10. The new
platform-os-max-allowed-address-pairs flag allows
users to customize the configuration, mirroring the
setting in their installation's neutron.conf.

The patch allows any custom configuration greater than
zero and disallows anything less than or equal to zero.
Finally, the default of 10 is still used as a fallback
if the user doesn't configure platform-os-max-allowed-address-pairs

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 15, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 15, 2026

Copy link
Copy Markdown

@danchild: This pull request references OSASINFRA-4400 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

TODO

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

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@danchild, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e0756e9-5e8c-40ba-bb0f-36f53c1633ac

📥 Commits

Reviewing files that changed from the base of the PR and between e70977a and 6fd36a0.

📒 Files selected for processing (1)
  • pkg/cloudprovider/openstack_test.go

Summary by CodeRabbit

  • New Features
    • Added a command-line option to configure the maximum number of allowed address pairs for OpenStack/Neutron.
    • OpenStack egress IP capacity calculations now honor the configured limit.
    • The default limit remains unchanged when no positive override is provided.
  • Bug Fixes
    • Added validation and clearer error reporting when the configured limit is too small for existing address pairs.

Walkthrough

Adds an OpenStack-specific max allowed address-pairs flag, stores the value in cloud provider configuration, applies positive overrides to egress capacity calculations, and expands related test coverage.

Changes

OpenStack capacity override

Layer / File(s) Summary
Capacity configuration and flag wiring
pkg/cloudprovider/cloudprovider.go, cmd/cloud-network-config-controller/main.go
Adds OSMaxAllowedAddressPairs to CloudProviderConfig and registers the platform-os-max-allowed-address-pairs flag with a default of 0.
Capacity selection and validation
pkg/cloudprovider/openstack.go, pkg/cloudprovider/openstack_test.go
Uses a positive configured value or the default capacity for egress calculations, preserves negative-capacity validation, and tests override and fallback behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: arkadeepsen, jcaamano

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant CloudProviderConfig
  participant OpenStack
  participant EgressConfiguration
  CLI->>CloudProviderConfig: Set OSMaxAllowedAddressPairs
  OpenStack->>CloudProviderConfig: Read configured capacity
  OpenStack->>OpenStack: Select configured or default ceiling
  OpenStack->>EgressConfiguration: Compute and validate egress IP capacity
Loading
🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: making OpenStack allowed address pairs configurable.
Description check ✅ Passed The description is directly related to the new configurable max allowed address pairs behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed All changed test titles are static strings; subtests use fixed tc.name values and no dynamic/generated identifiers appear.
Test Structure And Quality ✅ Passed New table-driven subtests cover one function, use SetupHTTP/TeardownHTTP like existing tests, and add meaningful t.Fatalf messages; no cluster waits/resources involved.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the only changed test is a standard Go unit test in pkg/cloudprovider with no MicroShift-specific APIs.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PASS: The patch only adds/updates package cloudprovider unit tests in openstack_test.go; no new Ginkgo e2e tests or SNO-sensitive cluster assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed Touched files only add an OpenStack flag/config field and capacity logic; no scheduling, nodeSelector, affinity, PDB, or topology checks were introduced.
Ote Binary Stdout Contract ✅ Passed PR only adds a flag and config logic; no new stdout writes or process-level print calls were introduced in main/init setup.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo/e2e tests were added; the only changed test is a standard unit test with no external connectivity or IPv4-only e2e assumptions.
No-Weak-Crypto ✅ Passed PR diff only adds/adjusts tests; searches of changed files found no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB usage or secret comparisons.
Container-Privileges ✅ Passed Only Go source files changed; no manifests or container security settings (privileged/hostPID/hostNetwork/allowPrivilegeEscalation/SYS_ADMIN) were added.
No-Sensitive-Data-In-Logs ✅ Passed PASS: The patch adds a flag/field and capacity logic only; no new log statements or secret-bearing messages were introduced, and the new error text only includes port ID/counts.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 15, 2026
@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Details 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

@danchild
danchild marked this pull request as ready for review July 15, 2026 17:18
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 15, 2026
@openshift-ci
openshift-ci Bot requested review from arkadeepsen and jcaamano July 15, 2026 17:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cmd/cloud-network-config-controller/main.go (1)

282-291: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use constant for platform type comparison.

Consider replacing the hardcoded "OpenStack" string with the cloudprovider.PlatformTypeOpenStack constant that is already used on line 205 of this file. This helps avoid magic strings and aligns with existing code patterns.

♻️ Proposed refactor
 	// determine if platform-os-max-allowed-address-pairs was set explicitly with a
 	// command line flag
-	if platformCfg.PlatformType == "OpenStack" {
+	if platformCfg.PlatformType == cloudprovider.PlatformTypeOpenStack {
 		flag.Visit(func(f *flag.Flag) {
 			if f.Name == "platform-os-max-allowed-address-pairs" {
 				platformCfg.OSMaxAllowedAddressPairs.SetByFlag = true
 			}
 		})
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/cloud-network-config-controller/main.go` around lines 282 - 291, In the
platform type check surrounding flag.Visit, replace the hardcoded "OpenStack"
comparison with the existing cloudprovider.PlatformTypeOpenStack constant. Keep
the explicit flag detection and SetByFlag assignment unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cmd/cloud-network-config-controller/main.go`:
- Around line 282-291: In the platform type check surrounding flag.Visit,
replace the hardcoded "OpenStack" comparison with the existing
cloudprovider.PlatformTypeOpenStack constant. Keep the explicit flag detection
and SetByFlag assignment unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 725d7b3c-7cab-4f58-84c3-6aafb21435c6

📥 Commits

Reviewing files that changed from the base of the PR and between 0b49df2 and 9aa6812.

📒 Files selected for processing (4)
  • cmd/cloud-network-config-controller/main.go
  • pkg/cloudprovider/cloudprovider.go
  • pkg/cloudprovider/openstack.go
  • pkg/cloudprovider/openstack_test.go

@danchild

Copy link
Copy Markdown
Member Author

/assign @arghosh93

@danchild
danchild force-pushed the openstack-allowed-address-pairs branch from 9aa6812 to d0174f3 Compare July 15, 2026 19:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
cmd/cloud-network-config-controller/main.go (1)

267-267: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Explicitly reject negative values for the flag.

While negative values are gracefully ignored during the capacity calculation (falling back to the default of 10), explicitly rejecting them during initialization prevents silent misconfigurations and strictly aligns with the PR objective ("zero or negative values are rejected"). As per path instructions, bounds-check user-supplied sizes.

Consider adding validation after flag.Parse():

	// Verify required arguments
	if secretName == "" || platformCfg.PlatformType == "" {
		klog.Exit("-secret-name or -platform-type is empty, cannot initialize controller")
	}
	if platformCfg.OSMaxAllowedAddressPairs < 0 {
		klog.Exit("-platform-os-max-allowed-address-pairs cannot be negative")
	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/cloud-network-config-controller/main.go` at line 267, Add initialization
validation after flag.Parse and the existing required-argument checks to reject
negative platformCfg.OSMaxAllowedAddressPairs via klog.Exit with a clear
flag-specific message. Preserve zero handling and the existing validation flow.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/cloudprovider/openstack.go`:
- Around line 611-613: Update the error message format string in the
address-pair capacity check to remove parentheses around all integer format
specifiers, while preserving the existing values, wording, and argument order.

---

Nitpick comments:
In `@cmd/cloud-network-config-controller/main.go`:
- Line 267: Add initialization validation after flag.Parse and the existing
required-argument checks to reject negative platformCfg.OSMaxAllowedAddressPairs
via klog.Exit with a clear flag-specific message. Preserve zero handling and the
existing validation flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 31799181-b9e8-493f-a5b4-8e0c8b2db34f

📥 Commits

Reviewing files that changed from the base of the PR and between 9aa6812 and d0174f3.

📒 Files selected for processing (4)
  • cmd/cloud-network-config-controller/main.go
  • pkg/cloudprovider/cloudprovider.go
  • pkg/cloudprovider/openstack.go
  • pkg/cloudprovider/openstack_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/cloudprovider/openstack_test.go

Comment thread pkg/cloudprovider/openstack.go Outdated
@danchild

Copy link
Copy Markdown
Member Author

/test e2e-azure-serial-2of2

@danchild

Copy link
Copy Markdown
Member Author

/test e2e-gcp-ovn

@danchild

Copy link
Copy Markdown
Member Author

/verified by @danchild

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 17, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@danchild: This PR has been marked as verified by @danchild.

Details

In response to this:

/verified by @danchild

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.

Currently, the maxmium allowed address pairs per port
is hardcoded to OpenStack's default of 10. The
`platform-os-max-allowed-address-pairs` flag allows
users to customize the configuration, mirroring the
setting in their installation's neutron.conf.

The patch allows any custom configuration greater than zero.
Finally, the default of 10 is still used as a fallback
if the user doesn't configure `platform-os-max-allowed-address-pairs`

Signed-off-by: Dan Childers <[email protected]>
@danchild
danchild force-pushed the openstack-allowed-address-pairs branch from d1a1b28 to 62be2d7 Compare July 20, 2026 13:26
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Jul 20, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/cloudprovider/openstack_test.go (1)

1084-1164: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add a test case to verify negative value fallback behavior.

The PR summary states that negative values are rejected, which the implementation handles by falling back to the default capacity (since the condition OSMaxAllowedAddressPairs > 0 evaluates to false). Consider explicitly adding a test case for a negative value to ensure this fallback behavior remains validated and prevents future regressions.

💡 Proposed addition to the test cases

You can append this case to the tcs slice:

		{
			name:                "negative flag uses default capacity",
			maxAllowedAddrPairs: -5,
			port:                portMap["9ab428d4-58f8-42d7-9672-90c3f5641f83"],
			nodeEgressIPConfig: NodeEgressIPConfiguration{
				Interface: "9ab428d4-58f8-42d7-9672-90c3f5641f83",
				IFAddr: ifAddr{
					IPv4: "192.0.2.0/24",
					IPv6: "2000::/64",
				},
				Capacity: capacity{
					IP: ptr.To(defaultOpenstackMaxCapacity - 5),
				},
			},
		},
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/cloudprovider/openstack_test.go` around lines 1084 - 1164, Add a
table-driven case to
TestGetNeutronPortNodeEgressIPConfigurationMaxAllowedAddressPairs with a
negative OSMaxAllowedAddressPairs value, such as -5, and expect the same default
capacity configuration as the existing “unset flag uses default capacity” case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/cloudprovider/openstack_test.go`:
- Around line 1084-1164: Add a table-driven case to
TestGetNeutronPortNodeEgressIPConfigurationMaxAllowedAddressPairs with a
negative OSMaxAllowedAddressPairs value, such as -5, and expect the same default
capacity configuration as the existing “unset flag uses default capacity” case.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: f9a0247c-1a73-4da0-b3d3-16fbca255aaa

📥 Commits

Reviewing files that changed from the base of the PR and between d0174f3 and 62be2d7.

📒 Files selected for processing (4)
  • cmd/cloud-network-config-controller/main.go
  • pkg/cloudprovider/cloudprovider.go
  • pkg/cloudprovider/openstack.go
  • pkg/cloudprovider/openstack_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/cloud-network-config-controller/main.go
  • pkg/cloudprovider/openstack.go

@danchild
danchild force-pushed the openstack-allowed-address-pairs branch from 62be2d7 to d68adfb Compare July 20, 2026 13:51
@danchild
danchild force-pushed the openstack-allowed-address-pairs branch from d68adfb to e70977a Compare July 30, 2026 18:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/cloudprovider/openstack_test.go (1)

1084-1179: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: add a combined override + existing-cloud-IPs case.

All four new subtests use cloudPrivateIPConfigs unset (cloudPrivateIPsCount == 0). Consider adding a case where a positive OSMaxAllowedAddressPairs override is combined with non-empty cloudPrivateIPConfigs, mirroring the existing default-path coverage in TestGetNeutronPortNodeEgressIPConfiguration (lines 1043-1057), to fully exercise the openstackMaxCapacity + cloudPrivateIPsCount - len(...) formula under override.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/cloudprovider/openstack_test.go` around lines 1084 - 1179, Add a table
case to TestGetNeutronPortNodeEgressIPConfigurationMaxAllowedAddressPairs
combining a positive maxAllowedAddrPairs override with non-empty
cloudPrivateIPConfigs, using the expected capacity from the override plus
cloud-private-IP count minus managed addresses. Mirror the existing default-path
scenario while preserving the current cases and assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/cloudprovider/openstack_test.go`:
- Around line 1084-1179: Add a table case to
TestGetNeutronPortNodeEgressIPConfigurationMaxAllowedAddressPairs combining a
positive maxAllowedAddrPairs override with non-empty cloudPrivateIPConfigs,
using the expected capacity from the override plus cloud-private-IP count minus
managed addresses. Mirror the existing default-path scenario while preserving
the current cases and assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: b5241aed-3534-4511-9331-73cf19d2f99f

📥 Commits

Reviewing files that changed from the base of the PR and between 62be2d7 and e70977a.

📒 Files selected for processing (1)
  • pkg/cloudprovider/openstack_test.go

@danchild
danchild force-pushed the openstack-allowed-address-pairs branch from e70977a to fa17726 Compare July 30, 2026 19:14
…irs arg

Coverage includes testing the following combinations of conditions:

- custom positive value overrides default
- unset flag uses default capacity
- custom value is too small
- negative values are overriden by default value

Signed-off-by: Dan Childers <[email protected]>
@danchild
danchild force-pushed the openstack-allowed-address-pairs branch from fa17726 to 6fd36a0 Compare July 30, 2026 19:24
@danchild

Copy link
Copy Markdown
Member Author

/verified by @danchild

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 30, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@danchild: This PR has been marked as verified by @danchild.

Details

In response to this:

/verified by @danchild

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.

@danchild

Copy link
Copy Markdown
Member Author

/test hypershift-e2e-aks

@openshift-ci

openshift-ci Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@danchild: all tests passed!

Full PR test history. Your PR dashboard.

Details

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.

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants