88 "time"
99
1010 envoy_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
11- "google.golang.org/protobuf/types/known/durationpb"
12-
1311 "github.com/go-viper/mapstructure/v2"
12+ "google.golang.org/protobuf/types/known/durationpb"
1413 "google.golang.org/protobuf/types/known/wrapperspb"
1514
1615 "github.com/hashicorp/consul/agent/structs"
@@ -215,13 +214,22 @@ func ToOutlierDetection(p *structs.PassiveHealthCheck, override *structs.Passive
215214 od .Consecutive_5Xx = & wrapperspb.UInt32Value {Value : p .MaxFailures }
216215 }
217216
218- if p .EnforcingConsecutive5xx != nil {
217+ if p .Consecutive5xx != nil && * p .Consecutive5xx != 0 {
218+ od .Consecutive_5Xx = & wrapperspb.UInt32Value {Value : * p .Consecutive5xx }
219+ }
220+
221+ if p .ConsecutiveGatewayFailure != nil && * p .ConsecutiveGatewayFailure != 0 {
222+ od .ConsecutiveGatewayFailure = & wrapperspb.UInt32Value {Value : * p .ConsecutiveGatewayFailure }
223+ }
224+
225+ if p .EnforcingConsecutive5xx != nil && (* p .EnforcingConsecutive5xx != 0 || allowZero ) {
219226 // NOTE: EnforcingConsecutive5xx must be greater than 0 for ingress-gateway
220- if * p .EnforcingConsecutive5xx != 0 {
221- od .EnforcingConsecutive_5Xx = & wrapperspb.UInt32Value {Value : * p .EnforcingConsecutive5xx }
222- } else if allowZero {
223- od .EnforcingConsecutive_5Xx = & wrapperspb.UInt32Value {Value : * p .EnforcingConsecutive5xx }
224- }
227+ od .EnforcingConsecutive_5Xx = & wrapperspb.UInt32Value {Value : * p .EnforcingConsecutive5xx }
228+ }
229+
230+ if p .EnforcingConsecutiveGatewayFailure != nil && (* p .EnforcingConsecutiveGatewayFailure != 0 || allowZero ) {
231+ // NOTE: EnforcingConsecutiveGatewayFailure must be greater than 0 for ingress-gateway
232+ od .EnforcingConsecutiveGatewayFailure = & wrapperspb.UInt32Value {Value : * p .EnforcingConsecutiveGatewayFailure }
225233 }
226234
227235 if p .MaxEjectionPercent != nil {
@@ -244,11 +252,24 @@ func ToOutlierDetection(p *structs.PassiveHealthCheck, override *structs.Passive
244252 od .Consecutive_5Xx = & wrapperspb.UInt32Value {Value : override .MaxFailures }
245253 }
246254
247- if override .EnforcingConsecutive5xx != nil {
255+ if override .Consecutive5xx != nil && * override .Consecutive5xx != 0 {
256+ od .Consecutive_5Xx = & wrapperspb.UInt32Value {Value : * override .Consecutive5xx }
257+ }
258+
259+ if override .ConsecutiveGatewayFailure != nil && * override .ConsecutiveGatewayFailure != 0 {
260+ od .ConsecutiveGatewayFailure = & wrapperspb.UInt32Value {Value : * override .ConsecutiveGatewayFailure }
261+ }
262+
263+ if override .EnforcingConsecutive5xx != nil && * override .EnforcingConsecutive5xx != 0 {
248264 // NOTE: EnforcingConsecutive5xx must be great than 0 for ingress-gateway
249- if * override .EnforcingConsecutive5xx != 0 {
250- od .EnforcingConsecutive_5Xx = & wrapperspb.UInt32Value {Value : * override .EnforcingConsecutive5xx }
251- }
265+ od .EnforcingConsecutive_5Xx = & wrapperspb.UInt32Value {Value : * override .EnforcingConsecutive5xx }
266+ // Because only ingress gateways have overrides and they cannot have a value of 0, there is no allowZero
267+ // override case to handle
268+ }
269+
270+ if override .EnforcingConsecutiveGatewayFailure != nil && * override .EnforcingConsecutiveGatewayFailure != 0 {
271+ // NOTE: EnforcingConsecutiveGatewayFailure must be greater than 0 for ingress-gateway
272+ od .EnforcingConsecutiveGatewayFailure = & wrapperspb.UInt32Value {Value : * override .EnforcingConsecutiveGatewayFailure }
252273 // Because only ingress gateways have overrides and they cannot have a value of 0, there is no allowZero
253274 // override case to handle
254275 }
0 commit comments