@@ -72,7 +72,10 @@ func translateTrafficFeatures(policy *egv1a1.ClusterSettings) (*ir.TrafficFeatur
72
72
ret .HTTP2 = h2
73
73
}
74
74
75
- ret .Retry = buildRetry (policy .Retry )
75
+ var err error
76
+ if ret .Retry , err = buildRetry (policy .Retry ); err != nil {
77
+ return nil , err
78
+ }
76
79
77
80
// If nothing was set in any of the above calls, return nil instead of an empty
78
81
// container
@@ -477,9 +480,9 @@ func translateDNS(policy egv1a1.ClusterSettings) *ir.DNS {
477
480
}
478
481
}
479
482
480
- func buildRetry (r * egv1a1.Retry ) * ir.Retry {
483
+ func buildRetry (r * egv1a1.Retry ) ( * ir.Retry , error ) {
481
484
if r == nil {
482
- return nil
485
+ return nil , nil
483
486
}
484
487
485
488
rt := & ir.Retry {}
@@ -518,13 +521,22 @@ func buildRetry(r *egv1a1.Retry) *ir.Retry {
518
521
if r .PerRetry .BackOff != nil {
519
522
if r .PerRetry .BackOff .MaxInterval != nil || r .PerRetry .BackOff .BaseInterval != nil {
520
523
bop := & ir.BackOffPolicy {}
524
+ if r .PerRetry .BackOff .BaseInterval != nil {
525
+ bop .BaseInterval = r .PerRetry .BackOff .BaseInterval
526
+ if bop .BaseInterval .Duration == 0 {
527
+ return nil , fmt .Errorf ("baseInterval cannot be set to 0s" )
528
+ }
529
+ }
521
530
if r .PerRetry .BackOff .MaxInterval != nil {
522
531
bop .MaxInterval = r .PerRetry .BackOff .MaxInterval
532
+ if bop .MaxInterval .Duration == 0 {
533
+ return nil , fmt .Errorf ("maxInterval cannot be set to 0s" )
534
+ }
535
+ if bop .BaseInterval != nil && bop .BaseInterval .Duration > bop .MaxInterval .Duration {
536
+ return nil , fmt .Errorf ("maxInterval cannot be less than baseInterval" )
537
+ }
523
538
}
524
539
525
- if r .PerRetry .BackOff .BaseInterval != nil {
526
- bop .BaseInterval = r .PerRetry .BackOff .BaseInterval
527
- }
528
540
pr .BackOff = bop
529
541
bpr = true
530
542
}
@@ -535,5 +547,5 @@ func buildRetry(r *egv1a1.Retry) *ir.Retry {
535
547
}
536
548
}
537
549
538
- return rt
550
+ return rt , nil
539
551
}
0 commit comments