0

Bug Description

I can smoothly work on adding multiple destinations for canary deployment but when I try adding retry it fails with the custom-built Helm chart. As I can't iterate over it.

This is a problem because Retry is tied to each destination according to that whole should be iterated.

Please find helm chart template below.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: {{ .Values.virtualservice.name }}
  namespace: {{ .Values.namespace }} 
spec:
  hosts:
  - {{ .Values.virtualservice.hosts }} 
  gateways:
  - {{ .Values.virtualservice.gateways }} 
  http:
  - route:
      {{- range $key, $value := .Values.destination }}
    - destination:
        host: {{ $value.host }}
        subset: {{ $value.subset }} 
      weight: {{ $value.weight }}
    retries:
      attempts: {{ $value.retries.attempts }}
      perTryTimeout: {{ $value.retries.perTryTimeout }}
      retryOn: {{ $value.retries.retryOn }}
    timeout: {{ $value.retries.timeout }}
    {{- end }}

Error log

$ helm install asm-helm ./asm-svc-helm-chart -f values.yaml --dry-run
Error: INSTALLATION FAILED: YAML parse error on asmvrtsvc/templates/retry-svc.yaml: error converting YAML to JSON: yaml: line 21: did not find expected key

Version

$ kubectl version --short
Client Version: v1.24.0
Kustomize Version: v4.5.4
Server Version: v1.22.12-gke.300

$ helm version
v3.9.4+gdbc6d8e

Added example for reference

spec:
  hosts:
  - reviews
  http:
  - route:
    - destination:
        host: reviews
        subset: v1
      weight: 75
    retries:
      attempts: 3
      perTryTimeout: 2s
    - destination:
        host: reviews
        subset: v2
      weight: 25
    retries:
      attempts: 3
      perTryTimeout: 2s
  • Is The line `{{- range $key, $value := .Values.destination }}` correct? if I were you, I put the line before `- route:` – hiroyukik Sep 20 '22 at 12:11
  • If we set at - route then based path or host we can set the configuration and that would work totally fine, but in this scenario, we are hitting the same URL and will perform canary deployment by providing weights to it along with retry policy for each destination. – Ajinkya Bhabal Sep 20 '22 at 13:19
  • 1
    According to the schema of virtual service*`,`retries` field should be one in a route. I think the loop should not include `retries` field. https://istio.io/latest/docs/reference/config/networking/virtual-service/ – hiroyukik Sep 20 '22 at 13:51

1 Answers1

1

According to the schema of Virtual Service, The route field in Virtual Service can have one retries field.

So, the loop should include destination as array.

*: https://istio.io/latest/docs/reference/config/networking/virtual-service/

hiroyukik
  • 713
  • 1
  • 6
  • 14