Skip to content

Commit

Permalink
Use request.add for header append operation
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprodan committed Mar 6, 2019
1 parent fe7547d commit eab7f12
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ spec:
# Envoy timeout and retry policy (optional)
headers:
request:
set:
add:
x-envoy-upstream-rq-timeout-ms: "15000"
x-envoy-max-retries: "10"
x-envoy-retry-on: "gateway-error,connect-failure,refused-stream"
Expand Down
2 changes: 1 addition & 1 deletion artifacts/canaries/canary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
# Envoy timeout and retry policy (optional)
headers:
request:
set:
add:
x-envoy-upstream-rq-timeout-ms: "15000"
x-envoy-max-retries: "10"
x-envoy-retry-on: "gateway-error,connect-failure,refused-stream"
Expand Down
2 changes: 1 addition & 1 deletion docs/gitbook/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ metadata:
# Envoy timeout and retry policy (optional)
headers:
request:
set:
add:
x-envoy-upstream-rq-timeout-ms: "15000"
x-envoy-max-retries: "10"
x-envoy-retry-on: "gateway-error,connect-failure,refused-stream"
Expand Down
12 changes: 6 additions & 6 deletions pkg/router/istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (ir *IstioRouter) Sync(canary *flaggerv1.Canary) error {
Rewrite: canary.Spec.Service.Rewrite,
Timeout: canary.Spec.Service.Timeout,
Retries: canary.Spec.Service.Retries,
AppendHeaders: setHeaders(canary),
AppendHeaders: addHeaders(canary),
Route: route,
},
},
Expand Down Expand Up @@ -201,7 +201,7 @@ func (ir *IstioRouter) SetRoutes(
Rewrite: canary.Spec.Service.Rewrite,
Timeout: canary.Spec.Service.Timeout,
Retries: canary.Spec.Service.Retries,
AppendHeaders: setHeaders(canary),
AppendHeaders: addHeaders(canary),
Route: []istiov1alpha3.DestinationWeight{
{
Destination: istiov1alpha3.Destination{
Expand Down Expand Up @@ -233,13 +233,13 @@ func (ir *IstioRouter) SetRoutes(
return nil
}

// setHeaders applies headers before forwarding a request to the destination service
// addHeaders applies headers before forwarding a request to the destination service
// compatible with Istio 1.0.x and 1.1.0
func setHeaders(canary *flaggerv1.Canary) (headers map[string]string) {
func addHeaders(canary *flaggerv1.Canary) (headers map[string]string) {
if canary.Spec.Service.Headers != nil &&
canary.Spec.Service.Headers.Request != nil &&
len(canary.Spec.Service.Headers.Request.Set) > 0 {
headers = canary.Spec.Service.Headers.Request.Set
len(canary.Spec.Service.Headers.Request.Add) > 0 {
headers = canary.Spec.Service.Headers.Request.Add
}

return
Expand Down

0 comments on commit eab7f12

Please sign in to comment.