Skip to content

Conversation

@kyrtapz
Copy link
Contributor

@kyrtapz kyrtapz commented Nov 7, 2025

Manual cherry-pick of #186.
Conflicts in pkg/cloudprovider/azure.go

@kyrtapz
Copy link
Contributor Author

kyrtapz commented Nov 7, 2025

/jira cherry-pick OCPBUGS-63753

@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@openshift-ci openshift-ci bot requested review from danwinship and tssurya November 7, 2025 08:51
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 7, 2025
@openshift-ci-robot
Copy link

@kyrtapz: Jira Issue OCPBUGS-63753 has been cloned as Jira Issue OCPBUGS-64779. Will retitle bug to link to clone.
/retitle OCPBUGS-64779: [release-4.18] Change the capacity struct from int to ptrOfInt

In response to this:

/jira cherry-pick OCPBUGS-63753

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 changed the title [release-4.18] Change the capacity struct from int to ptrOfInt OCPBUGS-64779: [release-4.18] Change the capacity struct from int to ptrOfInt Nov 7, 2025
@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 Nov 7, 2025
@openshift-ci-robot
Copy link

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

7 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.18.z) matches configured target version for branch (4.18.z)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)
  • release note type set to "Release Note Not Required"
  • dependent bug Jira Issue OCPBUGS-63753 is in the state Verified, which is one of the valid states (VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA))
  • dependent Jira Issue OCPBUGS-63753 targets the "4.19.z" version, which is one of the valid target versions: 4.19.0, 4.19.z
  • bug has dependents

Requesting review from QA contact:
/cc @anuragthehatter

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

In response to this:

Manual cherry-pick of #186.
Conflicts in pkg/cloudprovider/azure.go

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.

Today, in CNCC we store the capacity values as
integers:

type capacity struct {
  IPv4 int `json:"ipv4,omitempty"`
  IPv6 int `json:"ipv6,omitempty"`
  IP   int `json:"ip,omitempty"`
}

When capacity is full, CNCC sets the value to 0.
Also, depending on the platform it also ignores
setting fields it doesn't care about (example AWS
doesn't use IP, gcp and azure don't use IPv4 and IPv6).

However given we have omitempty set, this was omitting
the zero value in the annotation. When OVN-Kubernetes
reads this annotation it was then setting the capacity
to unlimited:

nodeEgressIPConfig := []nodeEgressIPConfiguration{
        {
            Capacity: Capacity{
                IP:   UnlimitedNodeCapacity,
                IPv4: UnlimitedNodeCapacity, --> we set this to maxint32
                IPv6: UnlimitedNodeCapacity,
            },
        },
    }

which is causing all EgressIPs to be
assigned to this node leading to:

status:
  conditions:
  - lastTransitionTime: "2025-10-06T19:24:24Z"
    message: "Error processing cloud assignment request, err: PrivateIpAddressLimitExceeded:
      Number of private addresses will exceed limit.\n\tstatus code: 400, request
      id: 457f4332-e9c4-44c9-bfcf-deeb5e7e43ce"

In this fix, what we really want is to remove omitempty
so that the zero capacity gets reflected correctly, however
doing so also means fields that are unset will also be zero
which can lead to confusion. Basically we are not able to
distinguish between unset field and 0 value fields.

Hence we are changing the capacity struct to be pointer type
values so that null/nil means unset and 0 means full capacity.
We still keep the omitempty since we don't need to do anything
with unset fields - there is no behaviour change there and
OVN-Kubernetes will continue to treat that as unlimited
capacity.

Upgrades: CNCC upon reboot seems to call:
func (n *NodeController) SyncHandler(key string) error {
....
	// Filter out cloudPrivateIPConfigs assigned to node (key) and write the entry
	// into same slice starting from index 0, finally chop off unwanted entries
	// when passing it into GetNodeEgressIPConfiguration.
	index := 0
	for _, cloudPrivateIPConfig := range cloudPrivateIPConfigs {
		if isAssignedCloudPrivateIPConfigOnNode(cloudPrivateIPConfig, key) {
			cloudPrivateIPConfigs[index] = cloudPrivateIPConfig
			index++
		}
	}
	nodeEgressIPConfigs, err := n.cloudProviderClient.GetNodeEgressIPConfiguration(node, cloudPrivateIPConfigs[:index])
	if err != nil {
		return fmt.Errorf("error retrieving the private IP configuration for node: %s, err: %v", node.Name, err)
	}
	return n.SetNodeEgressIPConfigAnnotation(node, nodeEgressIPConfigs)
}

// SetCloudPrivateIPConfigAnnotationOnNode annotates the corev1.Node with the cloud subnet information and capacity
func (n *NodeController) SetNodeEgressIPConfigAnnotation(node *corev1.Node, nodeEgressIPConfigs []*cloudprovider.NodeEgressIPConfiguration) error {
	annotation, err := n.generateAnnotation(nodeEgressIPConfigs)
	if err != nil {
		return err
	}
	klog.Infof("Setting annotation: '%s: %s' on node: %s", nodeEgressIPConfigAnnotationKey, annotation, node.Name)
	return retry.RetryOnConflict(retry.DefaultRetry, func() error {
		ctx, cancel := context.WithTimeout(n.ctx, controller.ClientTimeout)
		defer cancel()

		// See: updateCloudPrivateIPConfigStatus
		nodeLatest, err := n.kubeClient.CoreV1().Nodes().Get(ctx, node.Name, metav1.GetOptions{})
		if err != nil {
			return err
		}
		existingAnnotations := nodeLatest.Annotations
		existingAnnotations[nodeEgressIPConfigAnnotationKey] = annotation
		nodeLatest.SetAnnotations(existingAnnotations)
		_, err = n.kubeClient.CoreV1().Nodes().Update(ctx, nodeLatest, metav1.UpdateOptions{})
		return err
	})
}

and we seem to be overwriting the annotation - so we should be good on upgrades
in changing from older annotations to new annotations - where 0 valued fields
will appear for full capacity nodes.

Once that happens, OVN-Kubernetes should overrite the UnlimitedValue to value 0
tat indicates 0 capacity and we should enter:

			if eNode.egressIPConfig.Capacity.IP < util.UnlimitedNodeCapacity {
				if eNode.egressIPConfig.Capacity.IP-len(eNode.allocations) <= 0 {
					klog.V(5).Infof("Additional allocation on Node: %s exhausts it's IP capacity, trying another node", eNode.name)
					continue
				}
			}
			if eNode.egressIPConfig.Capacity.IPv4 < util.UnlimitedNodeCapacity && utilnet.IsIPv4(eIP) {
				if eNode.egressIPConfig.Capacity.IPv4-getIPFamilyAllocationCount(eNode.allocations, false) <= 0 {
					klog.V(5).Infof("Additional allocation on Node: %s exhausts it's IPv4 capacity, trying another node", eNode.name)
					continue
				}
			}
			if eNode.egressIPConfig.Capacity.IPv6 < util.UnlimitedNodeCapacity && utilnet.IsIPv6(eIP) {
				if eNode.egressIPConfig.Capacity.IPv6-getIPFamilyAllocationCount(eNode.allocations, true) <= 0 {
					klog.V(5).Infof("Additional allocation on Node: %s exhausts it's IPv6 capacity, trying another node", eNode.name)
					continue
				}
			}

these desired conditions correctly.

Conflicts in pkg/cloudprovider/azure.go

Signed-off-by: Surya Seetharaman <[email protected]>
(cherry picked from commit 66c4f5d)
@ricky-rav
Copy link
Contributor

@coderabbitai help

@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@ricky-rav ricky-rav left a comment

Choose a reason for hiding this comment

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

/LGTM

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 7, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kyrtapz, ricky-rav

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

The pull request process is described 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

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 7, 2025

@kyrtapz: 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/okd-scos-e2e-aws-ovn b2c1c68 link false /test okd-scos-e2e-aws-ovn
ci/prow/security b2c1c68 link false /test security
ci/prow/e2e-azure-ovn b2c1c68 link true /test e2e-azure-ovn

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.

@qiowang721
Copy link

/verified by @qiowang721
Tested on fresh installed aws passed, tested upgrade(4.17->4.18) on aws passed.

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Nov 8, 2025
@openshift-ci-robot
Copy link

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

In response to this:

/verified by @qiowang721
Tested on fresh installed aws passed, tested upgrade(4.17->4.18) on aws passed.

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.

@kyrtapz
Copy link
Contributor Author

kyrtapz commented Nov 12, 2025

/label backport-risk-assessed

@openshift-ci openshift-ci bot added the backport-risk-assessed Indicates a PR to a release branch has been evaluated and considered safe to accept. label Nov 12, 2025
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD beacfbc and 2 for PR HEAD b2c1c68 in total

@kyrtapz
Copy link
Contributor Author

kyrtapz commented Nov 12, 2025

/test okd-scos-e2e-aws-ovn

@kyrtapz
Copy link
Contributor Author

kyrtapz commented Nov 12, 2025

/cherry-pick release-4.17

@openshift-cherrypick-robot

@kyrtapz: once the present PR merges, I will cherry-pick it on top of release-4.17 in a new PR and assign it to you.

In response to this:

/cherry-pick release-4.17

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.

@kyrtapz
Copy link
Contributor Author

kyrtapz commented Nov 12, 2025

/test okd-scos-e2e-aws-ovn

@kyrtapz
Copy link
Contributor Author

kyrtapz commented Nov 12, 2025

The fix is unrelated to OKD which is failing on install
/override ci/prow/okd-scos-e2e-aws-ovn

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 12, 2025

@kyrtapz: Overrode contexts on behalf of kyrtapz: ci/prow/okd-scos-e2e-aws-ovn

In response to this:

The fix is unrelated to OKD which is failing on install
/override ci/prow/okd-scos-e2e-aws-ovn

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.

@openshift-merge-bot openshift-merge-bot bot merged commit 990d4d6 into openshift:release-4.18 Nov 12, 2025
10 of 11 checks passed
@openshift-ci-robot
Copy link

@kyrtapz: Jira Issue Verification Checks: Jira Issue OCPBUGS-64779
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-64779 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

In response to this:

Manual cherry-pick of #186.
Conflicts in pkg/cloudprovider/azure.go

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-cherrypick-robot

@kyrtapz: new pull request created: #191

In response to this:

/cherry-pick release-4.17

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.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. backport-risk-assessed Indicates a PR to a release branch has been evaluated and considered safe to accept. 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. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.