-
Notifications
You must be signed in to change notification settings - Fork 2
fix: backendRefUnknownKind test case #133
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 <[email protected]>
Signed-off-by: ashing <[email protected]>
Signed-off-by: ashing <[email protected]>
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 fixes the backend reference test case by updating the test suite as well as modifying error handling in backend reference translation and HTTPRoute reconciliation.
- Commented out the backendRef unknown kind test in the conformance tests.
- Updated translateBackendRef to return errors when an unsupported backend kind is provided and enhanced error handling in the HTTPRoute controller.
- Revised the license header in generated deepcopy files.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/conformance/conformance_test.go | Commented out the problematic backend reference test case to reflect updated behavior. |
| internal/provider/adc/translator/httproute.go | Modified translateBackendRef to validate backend kinds and return detailed errors. |
| internal/controller/utils.go | Adjusted condition reason assignment based on the error message content. |
| internal/controller/httproute_controller.go | Enhanced HTTPRoute reconciliation logic to propagate backend reference errors appropriately. |
| api/dashboard/v1/zz_generated.deepcopy.go | Updated the license header formatting. |
|
|
||
| tests.GatewayInvalidTLSConfiguration.ShortName, | ||
| tests.HTTPRouteInvalidBackendRefUnknownKind.ShortName, | ||
| // tests.HTTPRouteInvalidBackendRefUnknownKind.ShortName, |
Copilot
AI
May 9, 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.
[nitpick] Consider adding an inline comment explaining why the HTTPRouteInvalidBackendRefUnknownKind test is commented out to clarify that this change is intentional.
| // tests.HTTPRouteInvalidBackendRefUnknownKind.ShortName, | |
| // tests.HTTPRouteInvalidBackendRefUnknownKind.ShortName, // Commented out because this test is not applicable to the current implementation. See issue tracker for details. |
| func (t *Translator) translateBackendRef(tctx *provider.TranslateContext, ref gatewayv1.BackendRef) adctypes.UpstreamNodes { | ||
| func (t *Translator) translateBackendRef(tctx *provider.TranslateContext, ref gatewayv1.BackendRef) (adctypes.UpstreamNodes, error) { | ||
| if ref.Kind != nil && *ref.Kind != "Service" { | ||
| return adctypes.UpstreamNodes{}, fmt.Errorf("kind %s is not supported", *ref.Kind) |
Copilot
AI
May 9, 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.
Enhance the error message here by including additional context (e.g., backend reference name or namespace) to improve debugging when an unsupported kind is encountered.
| return adctypes.UpstreamNodes{}, fmt.Errorf("kind %s is not supported", *ref.Kind) | |
| key := types.NamespacedName{ | |
| Namespace: string(*ref.Namespace), | |
| Name: string(ref.Name), | |
| } | |
| return adctypes.UpstreamNodes{}, fmt.Errorf("kind %s is not supported for backend reference %s", *ref.Kind, key) |
| } | ||
|
|
||
| // If the backend reference error is because of an invalid kind, use this error first | ||
| if httpRouteErr != nil && strings.Contains(httpRouteErr.Error(), string(gatewayv1.RouteReasonInvalidKind)) { |
Copilot
AI
May 9, 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.
[nitpick] Consider adding logging for the backend reference error (httpRouteErr) before setting the resolveRefStatus so that the issue is more easily traceable in production environments.
| if httpRouteErr != nil && strings.Contains(httpRouteErr.Error(), string(gatewayv1.RouteReasonInvalidKind)) { | |
| if httpRouteErr != nil && strings.Contains(httpRouteErr.Error(), string(gatewayv1.RouteReasonInvalidKind)) { | |
| r.Log.Error(httpRouteErr, "Backend reference error due to invalid kind encountered while processing HTTPRoute") |
conformance test reportapiVersion: gateway.networking.k8s.io/v1
date: "2025-05-09T06:57:58Z"
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:
- GatewayInvalidTLSConfiguration
- GatewaySecretInvalidReferenceGrant
- GatewaySecretMissingReferenceGrant
- HTTPRouteHTTPSListener
- HTTPRouteHostnameIntersection
- HTTPRouteInvalidCrossNamespaceBackendRef
- HTTPRouteInvalidCrossNamespaceParentRef
- HTTPRouteInvalidNonExistentBackendRef
- HTTPRouteInvalidParentRefNotMatchingSectionName
- HTTPRouteInvalidReferenceGrant
- HTTPRouteListenerHostnameMatching
- HTTPRoutePartiallyInvalidViaInvalidReferenceGrant
- HTTPRouteReferenceGrant
statistics:
Failed: 0
Passed: 20
Skipped: 13
name: GATEWAY-HTTP
summary: Core tests partially succeeded with 13 test skips. |
Signed-off-by: ashing <[email protected]>
Signed-off-by: ashing [email protected]
Type of change:
What this PR does / why we need it:
Pre-submission checklist: