Skip to content

Commit

Permalink
Merge 978c3fa into backport/spatel/NET-1646-add-max-ejection-percent-…
Browse files Browse the repository at this point in the history
…and-base-ejection-time/eagerly-stunning-spaniel
  • Loading branch information
hc-github-team-consul-core authored May 4, 2023
2 parents e411ebe + 978c3fa commit d9bae3c
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
12 changes: 12 additions & 0 deletions charts/consul/templates/crd-servicedefaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ spec:
how upstream proxy instances will be monitored for removal
from the load balancing pool.
properties:
baseEjectionTime:
description: The base time that a host is ejected for. The
real time is equal to the base time multiplied by the number
of times the host has been ejected and is capped by
max_ejection_time (Default 300s). Defaults to 30s.
type: string
enforcing_consecutive_5xx:
description: EnforcingConsecutive5xx is the % chance
that a host will be actually ejected when an outlier
Expand All @@ -363,6 +369,12 @@ spec:
sweeps. Each sweep may remove hosts or return hosts
to the pool.
type: string
maxEjectionPercent:
description: The maximum % of an upstream cluster that
can be ejected due to outlier detection. Defaults to
10% but will eject at least one host regardless of the value.
format: int32
type: integer
maxFailures:
description: MaxFailures is the count of consecutive
failures that results in a host being removed from
Expand Down
10 changes: 10 additions & 0 deletions control-plane/api/v1alpha1/servicedefaults_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net"
"strings"
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
Expand Down Expand Up @@ -172,6 +173,13 @@ type PassiveHealthCheck struct {
// when an outlier status is detected through consecutive 5xx.
// This setting can be used to disable ejection or to ramp it up slowly.
EnforcingConsecutive5xx *uint32 `json:"enforcing_consecutive_5xx,omitempty"`
// The maximum % of an upstream cluster that can be ejected due to outlier detection.
// Defaults to 10% but will eject at least one host regardless of the value.
MaxEjectionPercent *uint32 `json:",omitempty" alias:"max_ejection_percent"`
// The base time that a host is ejected for. The real time is equal to the base time
// multiplied by the number of times the host has been ejected and is capped by
// max_ejection_time (Default 300s). Defaults to 30000ms or 30s.
BaseEjectionTime *time.Duration `json:",omitempty" alias:"base_ejection_time"`
}

type ServiceDefaultsDestination struct {
Expand Down Expand Up @@ -413,6 +421,8 @@ func (in *PassiveHealthCheck) toConsul() *capi.PassiveHealthCheck {
Interval: in.Interval.Duration,
MaxFailures: in.MaxFailures,
EnforcingConsecutive5xx: in.EnforcingConsecutive5xx,
MaxEjectionPercent: in.MaxEjectionPercent,
BaseEjectionTime: in.BaseEjectionTime,
}
}

Expand Down
24 changes: 24 additions & 0 deletions control-plane/api/v1alpha1/servicedefaults_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
},
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: pointer.Duration(10 * time.Second),
},
MeshGateway: MeshGateway{
Mode: "local",
Expand All @@ -110,6 +112,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
},
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(20),
BaseEjectionTime: pointer.Duration(20 * time.Second),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand All @@ -134,6 +138,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
},
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(30),
BaseEjectionTime: pointer.Duration(30 * time.Second),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand Down Expand Up @@ -197,6 +203,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
Interval: 2 * time.Second,
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: pointer.Duration(10 * time.Second),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "local",
Expand All @@ -220,6 +228,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
Interval: 2 * time.Second,
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(20),
BaseEjectionTime: pointer.Duration(20 * time.Second),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand All @@ -242,6 +252,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
Interval: 2 * time.Second,
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(30),
BaseEjectionTime: pointer.Duration(30 * time.Second),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand Down Expand Up @@ -348,6 +360,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
},
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: pointer.Duration(10 * time.Second),
},
MeshGateway: MeshGateway{
Mode: "local",
Expand All @@ -372,6 +386,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
},
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(20),
BaseEjectionTime: pointer.Duration(20 * time.Second),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand All @@ -395,6 +411,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
},
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(30),
BaseEjectionTime: pointer.Duration(30 * time.Second),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand Down Expand Up @@ -453,6 +471,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
Interval: 2 * time.Second,
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: pointer.Duration(10 * time.Second),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "local",
Expand All @@ -475,6 +495,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
Interval: 2 * time.Second,
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(20),
BaseEjectionTime: pointer.Duration(20 * time.Second),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand All @@ -496,6 +518,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
Interval: 2 * time.Second,
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(30),
BaseEjectionTime: pointer.Duration(30 * time.Second),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand Down
11 changes: 11 additions & 0 deletions control-plane/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ spec:
upstream proxy instances will be monitored for removal from
the load balancing pool.
properties:
baseEjectionTime:
description: The base time that a host is ejected for. The
real time is equal to the base time multiplied by the number
of times the host has been ejected and is capped by
max_ejection_time (Default 300s). Defaults to 30s.
type: string
enforcing_consecutive_5xx:
description: EnforcingConsecutive5xx is the % chance that
a host will be actually ejected when an outlier status
Expand All @@ -256,6 +262,12 @@ spec:
description: Interval between health check analysis sweeps.
Each sweep may remove hosts or return hosts to the pool.
type: string
maxEjectionPercent:
description: The maximum % of an upstream cluster that
can be ejected due to outlier detection. Defaults to
10% but will eject at least one host regardless of the value.
format: int32
type: integer
maxFailures:
description: MaxFailures is the count of consecutive failures
that results in a host being removed from the pool.
Expand Down Expand Up @@ -344,6 +356,12 @@ spec:
how upstream proxy instances will be monitored for removal
from the load balancing pool.
properties:
baseEjectionTime:
description: The base time that a host is ejected for. The
real time is equal to the base time multiplied by the number
of times the host has been ejected and is capped by
max_ejection_time (Default 300s). Defaults to 30s.
type: string
enforcing_consecutive_5xx:
description: EnforcingConsecutive5xx is the % chance
that a host will be actually ejected when an outlier
Expand All @@ -356,6 +374,12 @@ spec:
sweeps. Each sweep may remove hosts or return hosts
to the pool.
type: string
maxEjectionPercent:
description: The maximum % of an upstream cluster that
can be ejected due to outlier detection. Defaults to
10% but will eject at least one host regardless of the value.
format: int32
type: integer
maxFailures:
description: MaxFailures is the count of consecutive
failures that results in a host being removed from
Expand Down
3 changes: 3 additions & 0 deletions control-plane/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,6 @@ require (
replace github.com/hashicorp/consul/sdk => github.com/hashicorp/consul/sdk v0.4.1-0.20221021205723-cc843c4be892

go 1.19

replace github.com/hashicorp/consul/api => github.com/hashicorp/consul 07d54ee65d554620733216daf764fc53168a5563
replace github.com/hashicorp/consul/api/watch => github.com/hashicorp/consul 07d54ee65d554620733216daf764fc53168a5563

0 comments on commit d9bae3c

Please sign in to comment.