Skip to content

[fix] filter EndpointSlices by IP family for target group registration#4783

Open
shuqz wants to merge 2 commits into
kubernetes-sigs:mainfrom
shuqz:fix-4775-endpointslice-ipfamily-filter
Open

[fix] filter EndpointSlices by IP family for target group registration#4783
shuqz wants to merge 2 commits into
kubernetes-sigs:mainfrom
shuqz:fix-4775-endpointslice-ipfamily-filter

Conversation

@shuqz
Copy link
Copy Markdown
Collaborator

@shuqz shuqz commented Jun 4, 2026

Issue

#4775

Description

When --enable-endpoint-slices=true, the endpoint resolver listed every EndpointSlice for a Service without filtering by address family. For Services with both IPv4 and IPv6 EndpointSlices, this caused the controller to submit IPv4 pod addresses to an IPv6-only target group's RegisterTargets call, which AWS rejects with ValidationError: The IP address '...' is not a valid IPv6 address. The affected pods' readiness gates never flipped and stayed not-ready.

This change makes ResolvePodEndpoints accept the target group's ipAddressType and filter EndpointSlices to only those whose AddressType matches that family.

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • Manually tested
    i was able to reproduce issue from my side, and verified the error is gone after deploying fix.
  • Made sure the title of the PR is a good description that can go into the release notes

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉
  • Refactored something and made the world a better place 🌟

The endpoint resolver listed every EndpointSlice for a Service without
considering address family, so an IPv6 target group could receive IPv4
pod addresses and get rejected by RegisterTargets. The resolver now
filters slices to those matching the TGB's ipAddressType.
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 4, 2026
@k8s-ci-robot k8s-ci-robot requested a review from wweiwei-li June 4, 2026 01:04
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: shuqz

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

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

@k8s-ci-robot k8s-ci-robot requested a review from zac-nixon June 4, 2026 01:04
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 4, 2026
@shuqz shuqz changed the title Filter EndpointSlices by IP family for target group registration [fix] filter EndpointSlices by IP family for target group registration Jun 4, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 4, 2026

Codecov Report

❌ Patch coverage is 53.84615% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.07%. Comparing base (22cdb42) to head (6f4dfd2).
⚠️ Report is 75 commits behind head on main.

Files with missing lines Patch % Lines
pkg/targetgroupbinding/resource_manager.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4783      +/-   ##
==========================================
+ Coverage   56.09%   57.07%   +0.97%     
==========================================
  Files         388      396       +8     
  Lines       30932    31579     +647     
==========================================
+ Hits        17352    18024     +672     
+ Misses      12566    12497      -69     
- Partials     1014     1058      +44     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}

// tgbTargetIPAddressType returns the TGB's IP address type, defaulting to IPv4 when unset.
func tgbTargetIPAddressType(tgb *elbv2api.TargetGroupBinding) elbv2api.TargetGroupIPAddressType {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How about using endpointSliceAddressType ? each EndpointSlice has one AddressType

func endpointSliceAddressType(tgb *elbv2api.TargetGroupBinding) discovery.AddressType {
	if tgb.Spec.IPAddressType != nil && *tgb.Spec.IPAddressType == elbv2api.TargetGroupIPAddressTypeIPv6 {
		return discovery.AddressTypeIPv6
	}
	return discovery.AddressTypeIPv4
}

This way, we could make endpoint_resolve clean, only have kubernetes type

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants