feat: Add support for HTTPRoutePolicy in HTTPRoute reconciliation#93
Merged
Conversation
This commit updates the `HTTPRoutePolicy` CRD with more detailed validation for Kubernetes object references, adds status and ancestor information to the policy, and updates the corresponding controller and test files. Additionally, it refactors the `StringOrSlice` type and adjusts the indexing and translation logic.
This commit refactors the `common` package by moving the `Vars` and `StringOrSlice` types to the `adc` package. It also updates the `TargetReference` type to use `LocalPolicyTargetReferenceWithSectionName` from `gateway-api` and simplifies the CRD documentation. Additionally, it adjusts the import paths and type references in the `httproute.go` file to reflect these changes.
Contributor
conformance test reportapiVersion: gateway.networking.k8s.io/v1
date: "2025-04-17T10:02:00Z"
gatewayAPIChannel: standard
gatewayAPIVersion: v1.2.0
implementation:
contact: null
organization: API7
project: api7-ingress-controller
url: https://github.com/api7/api7-ingress-controller.git
version: v2.0.0
kind: ConformanceReport
mode: default
profiles:
- core:
failedTests:
- HTTPRoutePathMatchOrder
- HTTPRouteSimpleSameNamespace
result: failure
skippedTests:
- GatewayInvalidTLSConfiguration
- GatewaySecretInvalidReferenceGrant
- GatewaySecretMissingReferenceGrant
- GatewaySecretReferenceGrantAllInNamespace
- GatewaySecretReferenceGrantSpecific
- HTTPRouteExactPathMatching
- HTTPRouteHTTPSListener
- HTTPRouteHeaderMatching
- HTTPRouteHostnameIntersection
- HTTPRouteInvalidBackendRefUnknownKind
- HTTPRouteInvalidCrossNamespaceBackendRef
- HTTPRouteInvalidCrossNamespaceParentRef
- HTTPRouteInvalidNonExistentBackendRef
- HTTPRouteInvalidParentRefNotMatchingSectionName
- HTTPRouteInvalidReferenceGrant
- HTTPRouteListenerHostnameMatching
- HTTPRouteMatching
- HTTPRouteMatchingAcrossRoutes
- HTTPRoutePartiallyInvalidViaInvalidReferenceGrant
- HTTPRouteReferenceGrant
- HTTPRouteRequestHeaderModifier
- HTTPRouteWeight
statistics:
Failed: 2
Passed: 9
Skipped: 22
name: GATEWAY-HTTP
summary: Core tests failed with 2 test failures. |
AlinsRan
reviewed
Apr 17, 2025
AlinsRan
reviewed
Apr 17, 2025
The `updateHTTPRoutePolicyStatus` function is replaced with `modifyHTTPRoutePolicyStatus` to streamline the process, and a new function `clearHTTPRoutePolicyRedundantAncestor` is introduced to remove redundant ancestors. Additionally, the group in the test's targetRefs is updated to `gateway.networking.k8s.io`.
Remove unnecessary `kind` fields and list map keys in the HTTPRoutePolicy CRD. Add a new generic event channel and update predicates for more efficient event handling in the HTTPRouteReconciler.
This commit refactors the handling of HTTPRoutePolicy, including moving the `httpRoutePolicyPredicateOnUpdate` function and updating the type definitions. It also updates the e2e test for HTTPRoute to correct a typo in the test description.
| Loop: | ||
| for _, items := range c.policies { | ||
| for _, item := range items { | ||
| if item.Spec.Priority != policy.Spec.Priority || *item.Spec.Priority != *policy.Spec.Priority { |
There was a problem hiding this comment.
The condition combining a direct pointer comparison and a dereferenced value comparison is redundant and could potentially lead to a nil pointer dereference if either Spec.Priority is nil. Consider adding explicit nil checks and simplifying the comparison logic.
Suggested change
| if item.Spec.Priority != policy.Spec.Priority || *item.Spec.Priority != *policy.Spec.Priority { | |
| if item.Spec.Priority == nil || policy.Spec.Priority == nil { | |
| if item.Spec.Priority != policy.Spec.Priority { // One is nil, the other is not | |
| c.conflict = true | |
| break Loop | |
| } | |
| } else if *item.Spec.Priority != *policy.Spec.Priority { |
The import statements in `httproute_controller.go`, `httproutepolicy.go`, and `httproute.go` have been reordered to improve readability and maintain a consistent style across the files.
AlinsRan
reviewed
Apr 17, 2025
AlinsRan
reviewed
Apr 17, 2025
AlinsRan
reviewed
Apr 18, 2025
AlinsRan
approved these changes
Apr 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change:
What this PR does / why we need it:
Pre-submission checklist: