-
Notifications
You must be signed in to change notification settings - Fork 2
fix: remove duplicate logic #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Ashing Zheng <[email protected]>
conformance test report - apisix-standalone modeapiVersion: gateway.networking.k8s.io/v1
date: "2025-08-04T10:16:31Z"
gatewayAPIChannel: standard
gatewayAPIVersion: v1.2.0
implementation:
contact: null
organization: APISIX
project: apisix-ingress-controller
url: https://github.com/apache/apisix-ingress-controller.git
version: v2.0.0
kind: ConformanceReport
mode: default
profiles:
- core:
failedTests:
- HTTPRouteInvalidBackendRefUnknownKind
- HTTPRouteMatchingAcrossRoutes
result: failure
skippedTests:
- HTTPRouteHTTPSListener
statistics:
Failed: 2
Passed: 30
Skipped: 1
name: GATEWAY-HTTP
summary: Core tests failed with 2 test failures. |
conformance test report - apisix modeapiVersion: gateway.networking.k8s.io/v1
date: "2025-08-04T10:09:11Z"
gatewayAPIChannel: standard
gatewayAPIVersion: v1.2.0
implementation:
contact: null
organization: APISIX
project: apisix-ingress-controller
url: https://github.com/apache/apisix-ingress-controller.git
version: v2.0.0
kind: ConformanceReport
mode: default
profiles:
- core:
failedTests:
- HTTPRouteInvalidBackendRefUnknownKind
- HTTPRouteMatchingAcrossRoutes
result: failure
skippedTests:
- HTTPRouteHTTPSListener
statistics:
Failed: 2
Passed: 30
Skipped: 1
name: GATEWAY-HTTP
summary: Core tests failed with 2 test failures. |
conformance test reportapiVersion: gateway.networking.k8s.io/v1
date: "2025-08-04T10:18:32Z"
gatewayAPIChannel: standard
gatewayAPIVersion: v1.2.0
implementation:
contact: null
organization: APISIX
project: apisix-ingress-controller
url: https://github.com/apache/apisix-ingress-controller.git
version: v2.0.0
kind: ConformanceReport
mode: default
profiles:
- core:
result: partial
skippedTests:
- HTTPRouteHTTPSListener
statistics:
Failed: 0
Passed: 32
Skipped: 1
name: GATEWAY-HTTP
summary: Core tests partially succeeded with 1 test skips. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the codebase to remove duplicate logic for handling endpoint collection across multiple controllers. The main goal is to centralize the logic for collecting endpoints with EndpointSlice support and optional subset filtering.
- Consolidates duplicate endpoint collection logic into a single reusable function
- Extracts subset filtering logic into dedicated utility functions
- Simplifies controller code by replacing inline endpoint handling with function calls
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/controller/utils.go | Adds new consolidated endpoint collection functions and removes duplicate logic |
| internal/controller/ingress_controller.go | Replaces inline endpoint collection with centralized function call |
| internal/controller/httproute_controller.go | Replaces inline endpoint collection with centralized function call |
| internal/controller/gatewayproxy_controller.go | Updates function call to use new consolidated endpoint collection |
| internal/controller/apisixroute_controller.go | Replaces inline endpoint collection and removes duplicate filtering functions |
internal/controller/utils.go
Outdated
| } | ||
|
|
||
| return nil | ||
| return collectEndpointsWithEndpointSliceSupport(tctx, c, tctx, serviceNN, true, nil) |
Copilot
AI
Aug 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function signature has tctx passed twice as both the context parameter and the TranslateContext parameter. This creates confusion and should be clarified by using proper parameter names or removing the redundancy.
| // filterEndpointSliceByTargetPod filters item.Endpoints which is not a subset of labels | ||
| func filterEndpointSliceByTargetPod(ctx context.Context, c client.Client, item discoveryv1.EndpointSlice, labels map[string]string) discoveryv1.EndpointSlice { | ||
| item.Endpoints = utils.Filter(item.Endpoints, func(v discoveryv1.Endpoint) bool { | ||
| if v.TargetRef == nil || v.TargetRef.Kind != KindPod { |
Copilot
AI
Aug 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant KindPod is referenced but not defined in this file. This will cause a compilation error unless it's imported or defined elsewhere.
Signed-off-by: Ashing Zheng <[email protected]>
…e_logic Signed-off-by: Ashing Zheng <[email protected]>
internal/controller/utils.go
Outdated
|
|
||
| // collectEndpointsWithEndpointSliceSupport collects endpoints and adds them to the translate context | ||
| // It handles both EndpointSlice (K8s 1.19+) and Endpoints (K8s 1.18) APIs with automatic fallback | ||
| func collectEndpointsWithEndpointSliceSupport( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is too long and not clear enough.
My suggestion is:
- fetchServiceEndpoints
- resolveServiceEndpoints
- ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
Signed-off-by: Ashing Zheng <[email protected]>
Type of change:
What this PR does / why we need it:
Pre-submission checklist: