Skip to content

Conversation

@ronething
Copy link
Contributor

Type of change:

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches
  • Documentation
  • Refactor
  • Chore
  • CI/CD or Tests

What this PR does / why we need it:

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

Signed-off-by: Ashing Zheng <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2025

conformance test report - apisix-standalone mode

apiVersion: 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.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2025

conformance test report - apisix mode

apiVersion: 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.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2025

conformance test report

apiVersion: 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.

@ronething ronething requested a review from Copilot August 1, 2025 08:49
Copy link
Contributor

Copilot AI left a 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

}

return nil
return collectEndpointsWithEndpointSliceSupport(tctx, c, tctx, serviceNN, true, nil)
Copy link

Copilot AI Aug 1, 2025

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.

Copilot uses AI. Check for mistakes.
// 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 {
Copy link

Copilot AI Aug 1, 2025

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.

Copilot uses AI. Check for mistakes.
@ronething ronething requested a review from AlinsRan August 4, 2025 06:27

// 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(
Copy link
Contributor

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
  • ...

Copy link
Contributor Author

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]>
@ronething ronething merged commit 6ca4414 into release-v2-dev Aug 4, 2025
20 of 22 checks passed
@ronething ronething deleted the fix/dupliate_logic branch August 4, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants