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

Spatel/net 1646 add max ejection percent and base ejection time #2064

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ spec:
interval: 1s
maxFailures: 10
enforcing_consecutive_5xx: 60
maxEjectionPercent: 100
baseEjectionTime: 20s
- name: "bar"
limits:
maxConnections: 5
Expand Down
3 changes: 2 additions & 1 deletion charts/consul/templates/crd-exportedservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ spec:
the service to.
type: string
peer:
description: Peer is the name of the peer to export the service to.
description: Peer is the name of the peer to export the
service to.
type: string
samenessGroup:
description: SamenessGroup is the name of the sameness
Expand Down
28 changes: 28 additions & 0 deletions charts/consul/templates/crd-servicedefaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ 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 30000ms or 30s.
type: string
enforcing_consecutive_5xx:
description: EnforcingConsecutive5xx is the % chance that
a host will be actually ejected when an outlier status
Expand All @@ -285,6 +292,13 @@ 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 @@ -377,6 +391,13 @@ 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 30000ms or 30s.
type: string
enforcing_consecutive_5xx:
description: EnforcingConsecutive5xx is the % chance
that a host will be actually ejected when an outlier
Expand All @@ -389,6 +410,13 @@ 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
11 changes: 10 additions & 1 deletion control-plane/api/v1alpha1/servicedefaults_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
capi "github.com/hashicorp/consul/api"
"github.com/miekg/dns"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -19,6 +18,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"

"github.com/hashicorp/consul-k8s/control-plane/api/common"
capi "github.com/hashicorp/consul/api"
)

const (
Expand Down Expand Up @@ -184,6 +184,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:"maxEjectionPercent,omitempty"`
// 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 *metav1.Duration `json:"baseEjectionTime,omitempty"`
}

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

Expand Down
36 changes: 36 additions & 0 deletions control-plane/api/v1alpha1/servicedefaults_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
},
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: &metav1.Duration{
Duration: 10 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "local",
Expand All @@ -115,6 +119,10 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
},
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(20),
BaseEjectionTime: &metav1.Duration{
Duration: 20 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand All @@ -139,6 +147,10 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
},
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(30),
BaseEjectionTime: &metav1.Duration{
Duration: 30 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand Down Expand Up @@ -215,6 +227,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 @@ -238,6 +252,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 @@ -260,6 +276,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 @@ -386,6 +404,10 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
},
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: &metav1.Duration{
Duration: 10 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "local",
Expand All @@ -410,6 +432,10 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
},
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(20),
BaseEjectionTime: &metav1.Duration{
Duration: 20 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand All @@ -433,6 +459,10 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
},
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(30),
BaseEjectionTime: &metav1.Duration{
Duration: 30 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand Down Expand Up @@ -504,6 +534,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 @@ -526,6 +558,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 @@ -547,6 +581,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 @@ -72,7 +72,8 @@ spec:
the service to.
type: string
peer:
description: Peer is the name of the peer to export the service to.
description: Peer is the name of the peer to export the
service to.
type: string
samenessGroup:
description: SamenessGroup is the name of the sameness
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ 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 30000ms or 30s.
type: string
enforcing_consecutive_5xx:
description: EnforcingConsecutive5xx is the % chance that
a host will be actually ejected when an outlier status
Expand All @@ -281,6 +288,13 @@ 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 @@ -373,6 +387,13 @@ 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 30000ms or 30s.
type: string
enforcing_consecutive_5xx:
description: EnforcingConsecutive5xx is the % chance
that a host will be actually ejected when an outlier
Expand All @@ -385,6 +406,13 @@ 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
2 changes: 0 additions & 2 deletions control-plane/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,6 @@ github.com/hashicorp/consul-k8s/control-plane/cni v0.0.0-20220831174802-b8af6526
github.com/hashicorp/consul-server-connection-manager v0.1.0 h1:XCweGvMHzra88rYv2zxwwuUOjBUdcQmNKVrnQmt/muo=
github.com/hashicorp/consul-server-connection-manager v0.1.0/go.mod h1:XVVlO+Yk7aiRpspiHZkrrFVn9BJIiOPnQIzqytPxGaU=
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
github.com/hashicorp/consul/api v1.10.1-0.20230424202255-e47f3216e51b h1:6JQAVFzqHzB51SP55BOLoDsw6sVD2WGkNSOoxI1hVZ4=
github.com/hashicorp/consul/api v1.10.1-0.20230424202255-e47f3216e51b/go.mod h1:tXfrC6o0yFTgAW46xd5Ic8STHc9oIBcRVBcwhX5KNCQ=
github.com/hashicorp/consul/api v1.10.1-0.20230427155444-391ed069c461 h1:cbsTR88ShbvcRMqLU8K0atm4GmRr8UH4x4jX4e12RYE=
github.com/hashicorp/consul/api v1.10.1-0.20230427155444-391ed069c461/go.mod h1:tXfrC6o0yFTgAW46xd5Ic8STHc9oIBcRVBcwhX5KNCQ=
github.com/hashicorp/consul/proto-public v0.1.0 h1:O0LSmCqydZi363hsqc6n2v5sMz3usQMXZF6ziK3SzXU=
Expand Down