Skip to content

Commit

Permalink
Updates ParentRef Status Conditions
Browse files Browse the repository at this point in the history
Signed-off-by: danehans <daneyonhansen@gmail.com>
  • Loading branch information
danehans committed Oct 4, 2022
1 parent 9550009 commit 2cff44a
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ httpRoutes:
conditions:
- type: Accepted
status: "True"
reason: Accepted
message: Route is accepted
- type: ResolvedRefs
status: "False"
reason: UnsupportedValue
message: "RequestHeaderModifier Filter already configures request header: add-header-1 to be added, ignoring second entry"
xdsIR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ httpRoutes:
conditions:
- type: Accepted
status: "True"
reason: Accepted
message: Route is accepted
- type: ResolvedRefs
status: "False"
reason: UnsupportedValue
# Currently only one invalid value status will be set. If there are multiple, then only the latest is displayed until that issue is resolved.
message: "RequestHeaderModifier Filter already configures request header: set-header-4 to be added/set, ignoring second entry"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ httpRoutes:
conditions:
- type: Accepted
status: "True"
reason: Accepted
message: Route is accepted
- type: ResolvedRefs
status: "False"
reason: UnsupportedValue
message: "RequestHeaderModifier Filter already configures request header: rem-header-1 to be removed, ignoring second entry"
xdsIR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ httpRoutes:
conditions:
- type: Accepted
status: "True"
reason: Accepted
message: Route is accepted
- type: ResolvedRefs
status: "False"
reason: UnsupportedValue
message: "RequestHeaderModifier Filter already configures request header: some-header-1 to be removed, ignoring second entry"
xdsIR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ httpRoutes:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
conditions:
- type: Accepted
status: "True"
reason: Accepted
message: Route is accepted
- type: ResolvedRefs
status: "False"
reason: UnsupportedValue
message: "RequestHeaderModifier Filter cannot set a header with an empty name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ httpRoutes:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
conditions:
- type: Accepted
status: "True"
reason: Accepted
message: Route is accepted
- type: ResolvedRefs
status: "False"
reason: UnsupportedValue
message: "RequestHeaderModifier Filter cannot set headers with a '/' or ':' character in them. Header: 'example:1'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ httpRoutes:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
conditions:
- type: Accepted
status: "True"
reason: Accepted
message: Route is accepted
- type: ResolvedRefs
status: "False"
reason: UnsupportedValue
message: "RequestHeaderModifier Filter did not provide valid configuration to add/set/remove any headers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ httpRoutes:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
conditions:
- type: Accepted
status: "True"
reason: Accepted
message: Route is accepted
- type: ResolvedRefs
status: "False"
reason: UnsupportedValue
message: "Unknown custom filter type: UnsupportedType"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ httpRoutes:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
conditions:
- type: Accepted
status: "True"
reason: Accepted
message: Route is accepted
- type: ResolvedRefs
status: "False"
reason: UnsupportedValue
message: "Scheme: unknown is unsupported, only 'https' and 'http' are supported"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ httpRoutes:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
conditions:
- type: Accepted
status: "True"
reason: Accepted
message: Route is accepted
- type: ResolvedRefs
status: "False"
reason: UnsupportedValue
message: "Status code 666 is invalid, only 302 and 301 are supported"
Expand Down
43 changes: 18 additions & 25 deletions internal/gatewayapi/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
// Can't have two redirects for the same route
if redirectResponse != nil {
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
"Cannot configure multiple requestRedirect filters for a single HTTPRouteRule",
Expand All @@ -719,7 +719,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
} else {
errMsg := fmt.Sprintf("Scheme: %s is unsupported, only 'https' and 'http' are supported", *redirect.Scheme)
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
errMsg,
Expand All @@ -731,7 +731,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
if redirect.Hostname != nil {
if err := isValidHostname(string(*redirect.Hostname)); err != nil {
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
err.Error(),
Expand Down Expand Up @@ -760,7 +760,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
default:
errMsg := fmt.Sprintf("Redirect path type: %s is invalid, only \"ReplaceFullPath\" and \"ReplacePrefixMatch\" are supported", redirect.Path.Type)
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
errMsg,
Expand All @@ -777,7 +777,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
} else {
errMsg := fmt.Sprintf("Status code %d is invalid, only 302 and 301 are supported", redirectCode)
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
errMsg,
Expand Down Expand Up @@ -809,7 +809,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
emptyFilterConfig = false
if addHeader.Name == "" {
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
"RequestHeaderModifier Filter cannot add a header with an empty name",
Expand All @@ -820,7 +820,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
// Per Gateway API specification on HTTPHeaderName, : and / are invalid characters in header names
if strings.Contains(string(addHeader.Name), "/") || strings.Contains(string(addHeader.Name), ":") {
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
fmt.Sprintf("RequestHeaderModifier Filter cannot set headers with a '/' or ':' character in them. Header: %q", string(addHeader.Name)),
Expand All @@ -839,8 +839,8 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways

if !canAddHeader {
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
metav1.ConditionFalse,
v1beta1.RouteConditionAccepted,
metav1.ConditionTrue,
v1beta1.RouteReasonUnsupportedValue,
fmt.Sprintf("RequestHeaderModifier Filter already configures request header: %s to be added, ignoring second entry", headerKey),
)
Expand All @@ -866,7 +866,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways

if setHeader.Name == "" {
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
"RequestHeaderModifier Filter cannot set a header with an empty name",
Expand All @@ -876,7 +876,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
// Per Gateway API specification on HTTPHeaderName, : and / are invalid characters in header names
if strings.Contains(string(setHeader.Name), "/") || strings.Contains(string(setHeader.Name), ":") {
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
fmt.Sprintf("RequestHeaderModifier Filter cannot set headers with a '/' or ':' character in them. Header: '%s'", string(setHeader.Name)),
Expand All @@ -895,8 +895,8 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
}
if !canAddHeader {
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
metav1.ConditionFalse,
v1beta1.RouteConditionAccepted,
metav1.ConditionTrue,
v1beta1.RouteReasonUnsupportedValue,
fmt.Sprintf("RequestHeaderModifier Filter already configures request header: %s to be added/set, ignoring second entry", headerKey),
)
Expand All @@ -922,7 +922,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
for _, removedHeader := range headersToRemove {
if removedHeader == "" {
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
"RequestHeaderModifier Filter cannot remove a header with an empty name",
Expand All @@ -939,8 +939,8 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
}
if !canRemHeader {
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
metav1.ConditionFalse,
v1beta1.RouteConditionAccepted,
metav1.ConditionTrue,
v1beta1.RouteReasonUnsupportedValue,
fmt.Sprintf("RequestHeaderModifier Filter already configures request header: %s to be removed, ignoring second entry", removedHeader),
)
Expand All @@ -955,7 +955,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
// Update the status if the filter failed to configure any valid headers to add/remove
if len(addRequestHeaders) == 0 && len(removeRequestHeaders) == 0 && !emptyFilterConfig {
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
"RequestHeaderModifier Filter did not provide valid configuration to add/set/remove any headers",
Expand All @@ -966,7 +966,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
// Instead, requests that would have been processed by that filter MUST receive a HTTP error response."
errMsg := fmt.Sprintf("Unknown custom filter type: %s", filter.Type)
parentRef.SetCondition(
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
errMsg,
Expand Down Expand Up @@ -1119,13 +1119,6 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
v1beta1.RouteReasonNoMatchingListenerHostname,
"There were no hostname intersections between the HTTPRoute and this parent ref's Listener(s).",
)
} else {
parentRef.SetCondition(
v1beta1.RouteConditionAccepted,
metav1.ConditionTrue,
v1beta1.RouteReasonAccepted,
"Route is accepted",
)
}
}
}
Expand Down

0 comments on commit 2cff44a

Please sign in to comment.