-
Notifications
You must be signed in to change notification settings - Fork 532
Enhanced route error handling with early detection of incompatible filter combinations and enable direct response test #11456
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
base: main
Are you sure you want to change the base?
Enhanced route error handling with early detection of incompatible filter combinations and enable direct response test #11456
Conversation
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.
Thanks for taking a stab at this. Just a heads up that draft PRs don't trigger the full suite (e.g. e2e is disabled).
I think we'll likely need some more changes outside of re-enabling the suite and removing the ignore go build tags. We'll need to specify this suite in the
go-test-run-regex: '^TestKgateway$$/^BasicRouting$$|^TestKgateway$$/^HTTPRouteServices$$|^TestKgateway$$/^TLSRouteServices$$|^TestKgateway$$/^GRPCRouteServices$$|^TestListenerSet$$' |
- Added DirectResponse to the Kubernetes test regex for inclusion in tests. - Improved error handling in the DirectResponse plugin to use a sentinel error for route action conflicts. - Introduced ErrorPolicyIR to manage unresolved policies and prevent nil panics. - Implemented early detection of incompatible filters in route processing. - Updated tests to reflect changes in error handling and route conditions. Signed-off-by: MayorFaj <[email protected]>
Signed-off-by: MayorFaj <[email protected]>
Signed-off-by: MayorFaj <[email protected]>
…olicy error handling Signed-off-by: MayorFaj <[email protected]>
Signed-off-by: MayorFaj <[email protected]>
@@ -218,7 +215,7 @@ func (s *testingSuite) TestInvalidMissingRef() { | |||
) | |||
|
|||
s.ti.Assertions.EventuallyHTTPRouteStatusContainsReason(s.ctx, httpbinMeta.Name, httpbinMeta.Namespace, | |||
string(gwv1.RouteReasonBackendNotFound), 10*time.Second, 1*time.Second) | |||
string(gwv1.RouteReasonUnsupportedValue), 10*time.Second, 1*time.Second) |
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.
I believe missing policy should be a configuration error (configuration validation issues), not a backend resolution problem.
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.
I'd have to take a closer look at the updated changes.
For posterity, we were recently discussing how to handle attachment issues, which is relevant to the direct response plugin as you've discovered where the ApplyForRoute method returns a concrete error.
I think the approach we'll pursue in the short/medium term is introducing better CEL validation in our API definition to reject invalid attachment, and then handling the remaining edge cases (e.g. ExtensionRef in the context of direct response) in ApplyForX method error handling for GVKs we don't own (i.e. HTTPRoute).
Signed-off-by: MayorFaj <[email protected]>
Signed-off-by: MayorFaj <[email protected]>
@MayorFaj I think #11456 (comment) is still relevant here imo. I'd like to just focus on re-enabling the direct response suite like nathan suggested and handling any fail open scenarios issues in another issue/PR. Let me know if you're running into issues with re-enabling these test cases. I think we can figure out the right balance here. |
…t policies Signed-off-by: MayorFaj <[email protected]>
Signed-off-by: MayorFaj <[email protected]>
@timflannagan I am not sure I am clear on the comments. TestBasicDirectResponse PASS The test won't pass without a fix. |
@MayorFaj Ah, got it. That makes more sense looking at the plugin code and the existing suite logic.
Looking at this test case again, I think the assertions are potentially wrong? The parent route should have 302, but the child route should trigger route replacement and return a 500 response code.
The latter seems more correct, although I'm surprised looking at the implementation that RouteReasonBackendNotFound is returned? That test case doesn't configure a backendRefs, and the route translator uses attached backends when setting the envoy route action correctly, and the
That seems like a bug and may require explicit changes. We're configuring the RequestRedirect built-in filter in addition to extRef-ing the extension DR API. I would expect the built-in policy type to run first, it sets the output route action, and then the direct response plugin runs, and the plugin returns an error as the output route action has already been set. Edit: Just took another look at the code:
Hmm need to confirm whether this is intentional. |
This pull request introduces several enhancements and fixes to improve error handling, policy resolution, and route configuration in the
kgateway
project. Key updates include the addition of a newErrorPolicyIR
type for better error propagation, enhanced detection and handling of incompatible filters, and updates to Kubernetes test suites for theDirectResponse
feature.Improvements to error handling and policy resolution:
ErrorPolicyIR
for missing/failed policies: Added a new typeErrorPolicyIR
to represent unresolved or invalid policies, enabling safer error propagation without causing panics. [1] [2]RoutesIndex
andhttpRouteConfigurationTranslator
to createErrorPolicyIR
for missing policies and propagate errors with detailed logging. [1] [2]Improvements to route configuration:
DirectResponse
+RequestRedirect
) and implemented logic to return a 500 error response when such conflicts are detected. [1] [2]runRoutePlugins
to detect missing policies early and fail routes with appropriate error conditions. [1] [2]Updates to Kubernetes tests:
DirectResponse
test suite: Updated theDirectResponse
test suite to usetestdefaults.CurlPodExecOpt
instead ofdefaults.CurlPodExecOpt
, ensuring consistency across tests. [1] [2] [3] [4]Miscellaneous:
ErrRouteActionConflict
andErrMissingPolicy
for better error handling and type-safe detection of route conflicts.DirectResponse
in Kubernetes test regex: Updated the test regex for Kubernetes to include theDirectResponse
feature.Change Type
Changelog