Skip to content

Commit

Permalink
Add Contour timeout and retry policies
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprodan committed Dec 19, 2019
1 parent 02b579f commit 3acae04
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion pkg/router/contour.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func (cr *ContourRouter) Reconcile(canary *flaggerv1.Canary) error {
Prefix: "/",
},
},
TimeoutPolicy: cr.makeTimeoutPolicy(canary),
RetryPolicy: cr.makeRetryPolicy(canary),
Services: []contourv1.Service{
{
Name: primaryName,
Expand All @@ -58,7 +60,9 @@ func (cr *ContourRouter) Reconcile(canary *flaggerv1.Canary) error {
newSpec = contourv1.HTTPProxySpec{
Routes: []contourv1.Route{
{
Conditions: cr.makeConditions(canary),
Conditions: cr.makeConditions(canary),
TimeoutPolicy: cr.makeTimeoutPolicy(canary),
RetryPolicy: cr.makeRetryPolicy(canary),
Services: []contourv1.Service{
{
Name: primaryName,
Expand All @@ -78,6 +82,8 @@ func (cr *ContourRouter) Reconcile(canary *flaggerv1.Canary) error {
Prefix: "/",
},
},
TimeoutPolicy: cr.makeTimeoutPolicy(canary),
RetryPolicy: cr.makeRetryPolicy(canary),
Services: []contourv1.Service{
{
Name: primaryName,
Expand Down Expand Up @@ -317,3 +323,22 @@ func (cr *ContourRouter) makeConditions(canary *flaggerv1.Canary) []contourv1.Co

return list
}

func (cr *ContourRouter) makeTimeoutPolicy(canary *flaggerv1.Canary) *contourv1.TimeoutPolicy {
if canary.Spec.Service.Timeout != "" {
return &contourv1.TimeoutPolicy{
Response: canary.Spec.Service.Timeout,
}
}
return nil
}

func (cr *ContourRouter) makeRetryPolicy(canary *flaggerv1.Canary) *contourv1.RetryPolicy {
if canary.Spec.Service.Retries != nil {
return &contourv1.RetryPolicy{
NumRetries: uint32(canary.Spec.Service.Retries.Attempts),
PerTryTimeout: canary.Spec.Service.Retries.PerTryTimeout,
}
}
return nil
}

0 comments on commit 3acae04

Please sign in to comment.