Skip to content
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

Updates ParentRef Status Conditions #495

Merged
merged 2 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ httpRoutes:
status: "True"
danehans marked this conversation as resolved.
Show resolved Hide resolved
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:
envoy-gateway-gateway-1:
http:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ httpRoutes:
status: "True"
danehans marked this conversation as resolved.
Show resolved Hide resolved
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"
xdsIR:
envoy-gateway-gateway-1:
http:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ httpRoutes:
status: "True"
danehans marked this conversation as resolved.
Show resolved Hide resolved
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:
envoy-gateway-gateway-1:
http:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ httpRoutes:
status: "True"
danehans marked this conversation as resolved.
Show resolved Hide resolved
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:
envoy-gateway-gateway-1:
http:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ httpRoutes:
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"
xdsIR:
envoy-gateway-gateway-1:
http:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ httpRoutes:
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'"
xdsIR:
envoy-gateway-gateway-1:
http:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ httpRoutes:
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"
xdsIR:
envoy-gateway-gateway-1:
http:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ httpRoutes:
status: "True"
reason: Accepted
message: Route is accepted
- type: ResolvedRefs
status: "False"
reason: UnsupportedValue
message: "Unknown custom filter type: UnsupportedType"
xdsIR:
envoy-gateway-gateway-1:
http:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ httpRoutes:
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"
xdsIR:
envoy-gateway-gateway-1:
http:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ httpRoutes:
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"
xdsIR:
envoy-gateway-gateway-1:
http:
Expand Down
42 changes: 12 additions & 30 deletions internal/gatewayapi/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
// Can't have two redirects for the same route
if redirectResponse != nil {
parentRef.SetCondition(httpRoute,
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
"Cannot configure multiple requestRedirect filters for a single HTTPRouteRule",
Expand All @@ -801,7 +801,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(httpRoute,
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
errMsg,
Expand All @@ -813,7 +813,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
if redirect.Hostname != nil {
if err := isValidHostname(string(*redirect.Hostname)); err != nil {
parentRef.SetCondition(httpRoute,
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
err.Error(),
Expand Down Expand Up @@ -842,7 +842,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(httpRoute,
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
errMsg,
Expand All @@ -859,7 +859,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(httpRoute,
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
errMsg,
Expand Down Expand Up @@ -891,7 +891,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
emptyFilterConfig = false
if addHeader.Name == "" {
parentRef.SetCondition(httpRoute,
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
"RequestHeaderModifier Filter cannot add a header with an empty name",
Expand All @@ -902,7 +902,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(httpRoute,
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 @@ -920,12 +920,6 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
}

if !canAddHeader {
parentRef.SetCondition(httpRoute,
v1beta1.RouteConditionResolvedRefs,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
fmt.Sprintf("RequestHeaderModifier Filter already configures request header: %s to be added, ignoring second entry", headerKey),
)
continue
}

Expand All @@ -948,7 +942,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways

if setHeader.Name == "" {
parentRef.SetCondition(httpRoute,
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
"RequestHeaderModifier Filter cannot set a header with an empty name",
Expand All @@ -958,7 +952,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(httpRoute,
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 @@ -976,12 +970,6 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
}
}
if !canAddHeader {
parentRef.SetCondition(httpRoute,
v1beta1.RouteConditionResolvedRefs,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
fmt.Sprintf("RequestHeaderModifier Filter already configures request header: %s to be added/set, ignoring second entry", headerKey),
)
continue
}
newHeader := ir.AddHeader{
Expand All @@ -1004,7 +992,7 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
for _, removedHeader := range headersToRemove {
if removedHeader == "" {
parentRef.SetCondition(httpRoute,
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
"RequestHeaderModifier Filter cannot remove a header with an empty name",
Expand All @@ -1020,12 +1008,6 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
}
}
if !canRemHeader {
parentRef.SetCondition(httpRoute,
v1beta1.RouteConditionResolvedRefs,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
fmt.Sprintf("RequestHeaderModifier Filter already configures request header: %s to be removed, ignoring second entry", removedHeader),
)
continue
}

Expand All @@ -1037,7 +1019,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(httpRoute,
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
"RequestHeaderModifier Filter did not provide valid configuration to add/set/remove any headers",
Expand All @@ -1048,7 +1030,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(httpRoute,
v1beta1.RouteConditionResolvedRefs,
v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
v1beta1.RouteReasonUnsupportedValue,
errMsg,
Expand Down