nginx-gateway-fabric
nginx-gateway-fabric copied to clipboard
Apply configuration of SnippetsFilters to NGINX
Proposed changes
Problem: As a user of NGF, I want my SnippetsFilters configuration applied to NGF's data plane, so that I can leverage NGINX features not yet available in NGF.
Solution: Apply configuration of valid SnippetsFilters referenced in HTTPRoutes and GRPCRoutes to the appropriate contexts in the NGINX config. If the SnippetsFilter referenced is invalid (wrong group or kind), the routing rule is not configured. If the SnippetsFilter cannot be resolved, the routing rule is configured, but the route will return a 500.
Documentation will be added in a separate PR and is tracked by #2377.
Testing:
| Description | Expectation | ✅ |
|---|---|---|
| Basic Example. Route that references a valid SnippetsFilter. | Snippets applied to appropriate contexts. | ✅ |
| Route with multiple rules, with one that references a valid SnippetsFilter. | Location snippets only applied to location corresponding to the rule with the SnippetsFilter | ✅ |
| Route that references a SnippetsFilter with invalid group. | Route not configured. Accepted:False | ✅ |
| Route that references a SnippetsFilter with invalid kind. | Route not configured. Accepted:False | ✅ |
| Route that references a SnippetsFilter that doesn't exist. | Route configured and returns 500. Accepted:True ResolvedRefs:False | ✅ |
| Route with multiple distinct SnippetsFilters in the same rule | All snippets applied to appropriate contexts. | ✅ |
| Route with multiple distinct SnippetsFilters in different rules | Location snippets applied distinctly to the right locations. Main, http, and server contexts "merged" (two included per context) | ✅ |
| Route with multiple rules that reference same SnippetsFilter | Snippets are deduplicated, only one include per context. | ✅ |
| Route with a single rule that reference the same SnippetsFilter twice | Snippets are deduplicated, only one include per context. | ✅ |
| Multiple routes with distinct SnippetsFilters and same listener | Snippets are merged at main, http, and server context, and distinct in the listener context. | ✅ |
| Multiple routes with distinct SnippetsFilters and different listener | Snippets are merged at main, and http contexts, and distinct in the http and listener contexts. | ✅ |
| Multiple routes with the same SnippetsFilters and same listener | Snippets are deduplicated, only one include per context. | ✅ |
| Route with a valid filter and invalid ExtensionRef filter | Route not configured. Accepted:False | ✅ |
| Route with a valid filter and unresolvable ExtensionRef filter | Route configured and returns a 500. Accepted:True ResolvedRefs:False | ✅ |
Closes #2417
Checklist
Before creating a PR, run through this checklist and mark each as complete.
- [x] I have read the CONTRIBUTING doc
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] I have checked that all unit tests pass after adding my changes
- [ ] I have updated necessary documentation
- [x] I have rebased my branch onto main
- [ ] I will ensure my PR is targeting the main branch and pulling from my branch from my own fork
Release notes
If this PR introduces a change that affects users and needs to be mentioned in the release notes, please add a brief note that summarizes the change.
None