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: 48 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.

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: Enterprise

Run ID: 3860ad62-4598-4066-824e-a3ac3fe840f1

📥 Commits

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

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

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 calculation and validation coverage
pkg/cloudprovider/openstack.go, pkg/cloudprovider/openstack_test.go
Uses a positive configured value or the default capacity for egress calculations, preserves the negative-capacity error, and tests overrides, fallback behavior, and updated expectations.

Estimated code review effort: 2 (Simple) | ~15 minutes

Suggested reviewers: arkadeepsen, jcaamano

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant CloudProviderConfig
  participant OpenStack
  CLI->>CloudProviderConfig: Set OSMaxAllowedAddressPairs
  OpenStack->>CloudProviderConfig: Read configured capacity
  OpenStack->>OpenStack: Select configured or default capacity
  OpenStack->>OpenStack: Compute egress IP capacity
Loading
🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: making OpenStack allowed address pairs configurable.
Description check ✅ Passed The description matches the PR, explaining the new flag, accepted values, and default fallback.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 The added test uses static t.Run names; no Ginkgo titles or dynamic identifiers appear in the modified tests.
Test Structure And Quality ✅ Passed The new tests are plain unit tests, not Ginkgo; they use isolated t.Run cases, existing HTTP mock teardown, and clear t.Fatalf messages.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the only test changes are standard Go unit tests, with no MicroShift-unsupported APIs or features.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The added tests are plain Go unit tests using testing.T, with no Ginkgo e2e constructs or multi-node/SNO assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed Changes only add OpenStack max-allowed-address-pairs config/capacity logic and tests; no pod spec, nodeSelector, affinity, spread, or replica changes.
Ote Binary Stdout Contract ✅ Passed The PR only adds an init() flag for OpenStack config; no new process-level stdout writes or logging redirection regressions were introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Only standard testing.T unit tests were added; no Ginkgo e2e tests, IPv4-only assertions, or external connectivity requirements were introduced.
No-Weak-Crypto ✅ Passed Touched files only add an OpenStack config flag and capacity logic; no MD5/SHA1/DES/RC4/ECB or secret-comparison code was introduced.
Container-Privileges ✅ Passed The PR only changes Go config/OpenStack logic; repo scans found no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, or allowPrivilegeEscalation settings in manifests.
No-Sensitive-Data-In-Logs ✅ Passed PASS: The PR adds a config flag and capacity logic only; no new log statements or sensitive values are introduced in touched code.
✨ 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

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 <dchilder@redhat.com>
@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 on lines +611 to +613
return nil, fmt.Errorf("max allowed address pairs (%d) is too small for port %s which already has (%d) allowed address pairs and (%d) managed by CNCC",
openstackMaxCapacity, p.ID, len(p.AllowedAddressPairs), cloudPrivateIPsCount)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove parentheses around the format specifiers.

The formatting (%d) around the integer counts produces unusual output (e.g., "which already has (5) allowed address pairs"). Removing the parentheses improves readability. Additionally, this avoids breaking test assertions that check for unparenthesized substrings, as observed in the accompanying tests.

💡 Proposed fix
-		return nil, fmt.Errorf("max allowed address pairs (%d) is too small for port %s which already has (%d) allowed address pairs and (%d) managed by CNCC",
+		return nil, fmt.Errorf("max allowed address pairs (%d) is too small for port %s which already has %d allowed address pairs and %d managed by CNCC",
 			openstackMaxCapacity, p.ID, len(p.AllowedAddressPairs), cloudPrivateIPsCount)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return nil, fmt.Errorf("max allowed address pairs (%d) is too small for port %s which already has (%d) allowed address pairs and (%d) managed by CNCC",
openstackMaxCapacity, p.ID, len(p.AllowedAddressPairs), cloudPrivateIPsCount)
}
return nil, fmt.Errorf("max allowed address pairs (%d) is too small for port %s which already has %d allowed address pairs and %d managed by CNCC",
openstackMaxCapacity, p.ID, len(p.AllowedAddressPairs), cloudPrivateIPsCount)
}
🤖 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.go` around lines 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.

…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

Signed-off-by: Dan Childers <dchilder@redhat.com>
@danchild
danchild force-pushed the openstack-allowed-address-pairs branch from d0174f3 to d1a1b28 Compare July 16, 2026 14:06
@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@danchild: 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/security d1a1b28 link false /test security
ci/prow/e2e-gcp-ovn d1a1b28 link true /test e2e-gcp-ovn
ci/prow/e2e-azure-serial-2of2 d1a1b28 link true /test e2e-azure-serial-2of2

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants