Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Lubron Zhan <lubronzhan@gmail.com>
  • Loading branch information
lubronzhan committed Mar 1, 2024
1 parent 725ce9b commit dafd902
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/dag/gatewayapi_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1459,14 +1459,14 @@ func (p *GatewayAPIProcessor) computeHTTPRouteForListener(
gatewayapi_v1.RouteConditionAccepted,
meta_v1.ConditionFalse,
status.ReasonRouteRuleMatchConflict,
"HTTPRoute's Match has conflict with other HTTPRoute's Match",
status.MessageRouteRuleMatchConflict,
)
} else if invalidRuleCnt > 0 {
routeAccessor.AddCondition(
gatewayapi_v1.RouteConditionPartiallyInvalid,
meta_v1.ConditionTrue,
status.ReasonRouteRuleMatchPartiallyConflict,
"Dropped Rule: HTTPRoute's rule(s) has(ve) been droped because of conflict against other HTTPRoute's rule(s)",
status.MessageRouteRuleMatchPartiallyConflict,
)
}
}
Expand Down
3 changes: 3 additions & 0 deletions internal/status/routeconditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const (
ReasonInvalidGateway gatewayapi_v1.RouteConditionReason = "InvalidGateway"
ReasonRouteRuleMatchConflict gatewayapi_v1.RouteConditionReason = "RuleMatchConflict"
ReasonRouteRuleMatchPartiallyConflict gatewayapi_v1.RouteConditionReason = "RuleMatchPartiallyConflict"

MessageRouteRuleMatchConflict string = "HTTPRoute's Match has conflict with other HTTPRoute's Match"
MessageRouteRuleMatchPartiallyConflict string = "Dropped Rule: HTTPRoute's rule(s) has(ve) been dropped because of conflict against other HTTPRoute's rule(s)"
)

// RouteStatusUpdate represents an atomic update to a
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/gatewayapi_predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func HTTPRouteNotAcceptedDueToConflict(route *gatewayapi_v1.HTTPRoute) bool {
}

for _, gw := range route.Status.Parents {
if conditionExistsWithAllKeys(gw.Conditions, string(gatewayapi_v1.RouteConditionAccepted), meta_v1.ConditionFalse, string(status.ReasonRouteRuleMatchConflict), "HTTPRoute's Match has conflict with other HTTPRoute's Match") {
if conditionExistsWithAllKeys(gw.Conditions, string(gatewayapi_v1.RouteConditionAccepted), meta_v1.ConditionFalse, string(status.ReasonRouteRuleMatchConflict), status.MessageRouteRuleMatchConflict) {
return false
}
}
Expand All @@ -147,7 +147,7 @@ func HTTPRoutePartiallyAccepted(route *gatewayapi_v1.HTTPRoute) bool {
}

for _, gw := range route.Status.Parents {
if conditionExistsWithAllKeys(gw.Conditions, string(gatewayapi_v1.RouteConditionPartiallyInvalid), meta_v1.ConditionTrue, string(status.ReasonRouteRuleMatchPartiallyConflict), "Dropped Rule: HTTPRoute's rule(s) has(ve) been droped because of conflict against other HTTPRoute's rule(s)") {
if conditionExistsWithAllKeys(gw.Conditions, string(gatewayapi_v1.RouteConditionPartiallyInvalid), meta_v1.ConditionTrue, string(status.ReasonRouteRuleMatchPartiallyConflict), status.MessageRouteRuleMatchPartiallyConflict) {
return false
}
}
Expand Down

0 comments on commit dafd902

Please sign in to comment.