Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of Spatel/net 1646 add max ejection percent and base ejection time into release/1.0.x #2106

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 4 additions & 5 deletions control-plane/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ require (
github.com/deckarep/golang-set v1.7.1
github.com/fsnotify/fsnotify v1.5.4
github.com/go-logr/logr v0.4.0
github.com/google/go-cmp v0.5.7
github.com/google/go-cmp v0.5.8
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/hashicorp/consul-k8s/control-plane/cni v0.0.0-20220831174802-b8af65262de8
github.com/hashicorp/consul-server-connection-manager v0.1.0
github.com/hashicorp/consul/api v1.17.0
github.com/hashicorp/consul/sdk v0.13.0
github.com/hashicorp/consul/api v1.10.1-0.20230426225948-5eaeb7b8e563
github.com/hashicorp/consul/sdk v0.13.1
github.com/hashicorp/go-discover v0.0.0-20200812215701-c4b85f6ed31f
github.com/hashicorp/go-hclog v1.2.2
github.com/hashicorp/go-multierror v1.1.1
Expand Down Expand Up @@ -112,13 +112,12 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/tools v0.2.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.43.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
Expand Down
Loading