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

fix(common): Don't render backendRefs with RequestRedirect in GW API routes #391

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 2 additions & 5 deletions charts/library/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v2
name: common
description: Function library for Helm charts
type: library
version: 3.7.2
version: 3.7.3
kubeVersion: ">=1.22.0-0"
keywords:
- common
Expand All @@ -17,7 +17,4 @@ annotations:
artifacthub.io/changes: |-
- kind: fixed
description: |-
The Apache 2.0 LICENSE file has been added to the chart.
- kind: fixed
description: |-
Fixed non-deterministic selection of primary service and port.
fixes rendering of backendRefs with RequestRedirects filters.
34 changes: 21 additions & 13 deletions charts/library/common/templates/classes/_route.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,34 @@ spec:
{{- end }}
rules:
{{- range $routeObject.rules }}
- backendRefs:
{{- range .backendRefs }}
{{ $service := include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" .name) | fromYaml -}}
{{ $servicePrimaryPort := dict -}}
{{ if $service -}}
{{ $servicePrimaryPort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $service) | fromYaml -}}
{{- $hasRequestRedirect := false -}}
{{- range .filters }}
{{- if eq .type "RequestRedirect" }}
{{- $hasRequestRedirect = true -}}
{{- end }}
{{- end }}
{{- if not $hasRequestRedirect }}
- backendRefs:
{{- range .backendRefs }}
{{ $service := include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" .name) | fromYaml -}}
{{ $servicePrimaryPort := dict -}}
{{ if $service -}}
{{ $servicePrimaryPort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $service) | fromYaml -}}
{{- end }}
- group: {{ default "" .group | quote}}
kind: {{ default "Service" .kind }}
name: {{ default .name $service.name }}
namespace: {{ default $rootContext.Release.Namespace .namespace }}
port: {{ default .port $servicePrimaryPort.port }}
weight: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" .weight "default" 1) }}
{{- end }}
- group: {{ default "" .group | quote}}
kind: {{ default "Service" .kind }}
name: {{ default .name $service.name }}
namespace: {{ default $rootContext.Release.Namespace .namespace }}
port: {{ default .port $servicePrimaryPort.port }}
weight: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" .weight "default" 1) }}
{{- end }}
{{- if or (eq $routeKind "HTTPRoute") (eq $routeKind "GRPCRoute") }}
{{- with .matches }}
matches:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .filters }}
{{- with .filters }}
filters:
{{- toYaml . | nindent 6 }}
{{- end }}
Expand Down