Skip to content

Commit

Permalink
backport of [1484](#1484)
Browse files Browse the repository at this point in the history
  • Loading branch information
malizz authored and wilkermichael committed Sep 29, 2022
1 parent ce1af95 commit d0297de
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ spec:
passiveHealthCheck:
interval: 1s
maxFailures: 10
enforcing_consecutive_5xx: 60
- name: "bar"
limits:
maxConnections: 5
Expand Down
14 changes: 14 additions & 0 deletions charts/consul/templates/crd-servicedefaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ spec:
upstream proxy instances will be monitored for removal from
the load balancing pool.
properties:
enforcing_consecutive_5xx:
description: EnforcingConsecutive5xx is the % chance that
a host will be actually ejected when an outlier status
is detected through consecutive 5xx. This setting can
be used to disable ejection or to ramp it up slowly.
format: int32
type: integer
interval:
description: Interval between health check analysis sweeps.
Each sweep may remove hosts or return hosts to the pool.
Expand Down Expand Up @@ -333,6 +340,13 @@ spec:
how upstream proxy instances will be monitored for removal
from the load balancing pool.
properties:
enforcing_consecutive_5xx:
description: EnforcingConsecutive5xx is the % chance
that a host will be actually ejected when an outlier
status is detected through consecutive 5xx. This setting
can be used to disable ejection or to ramp it up slowly.
format: int32
type: integer
interval:
description: Interval between health check analysis
sweeps. Each sweep may remove hosts or return hosts
Expand Down
10 changes: 8 additions & 2 deletions control-plane/api/v1alpha1/servicedefaults_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ type PassiveHealthCheck struct {
// MaxFailures is the count of consecutive failures that results in a host
// being removed from the pool.
MaxFailures uint32 `json:"maxFailures,omitempty"`
// EnforcingConsecutive5xx is the % chance that a host will be actually ejected
// 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"`
}

type ServiceDefaultsDestination struct {
Expand Down Expand Up @@ -386,9 +390,11 @@ func (in *PassiveHealthCheck) toConsul() *capi.PassiveHealthCheck {
if in == nil {
return nil
}

return &capi.PassiveHealthCheck{
Interval: in.Interval.Duration,
MaxFailures: in.MaxFailures,
Interval: in.Interval.Duration,
MaxFailures: in.MaxFailures,
EnforcingConsecutive5xx: in.EnforcingConsecutive5xx,
}
}

Expand Down
49 changes: 31 additions & 18 deletions control-plane/api/v1alpha1/servicedefaults_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
)

func TestServiceDefaults_ToConsul(t *testing.T) {
Expand Down Expand Up @@ -82,7 +83,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(20),
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
},
MeshGateway: MeshGateway{
Mode: "local",
Expand All @@ -106,7 +108,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(10),
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand All @@ -129,7 +132,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(10),
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand Down Expand Up @@ -188,8 +192,9 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
MaxConcurrentRequests: intPointer(10),
},
PassiveHealthCheck: &capi.PassiveHealthCheck{
Interval: 2 * time.Second,
MaxFailures: uint32(20),
Interval: 2 * time.Second,
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "local",
Expand All @@ -210,8 +215,9 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
MaxConcurrentRequests: intPointer(5),
},
PassiveHealthCheck: &capi.PassiveHealthCheck{
Interval: 2 * time.Second,
MaxFailures: uint32(10),
Interval: 2 * time.Second,
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand All @@ -231,8 +237,9 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
MaxConcurrentRequests: intPointer(2),
},
PassiveHealthCheck: &capi.PassiveHealthCheck{
Interval: 2 * time.Second,
MaxFailures: uint32(10),
Interval: 2 * time.Second,
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand Down Expand Up @@ -335,7 +342,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(20),
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
},
MeshGateway: MeshGateway{
Mode: "local",
Expand All @@ -358,7 +366,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(10),
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand All @@ -380,7 +389,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(10),
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand Down Expand Up @@ -436,8 +446,9 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
MaxConcurrentRequests: intPointer(10),
},
PassiveHealthCheck: &capi.PassiveHealthCheck{
Interval: 2 * time.Second,
MaxFailures: uint32(20),
Interval: 2 * time.Second,
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "local",
Expand All @@ -457,8 +468,9 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
MaxConcurrentRequests: intPointer(5),
},
PassiveHealthCheck: &capi.PassiveHealthCheck{
Interval: 2 * time.Second,
MaxFailures: uint32(10),
Interval: 2 * time.Second,
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand All @@ -477,8 +489,9 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
MaxConcurrentRequests: intPointer(2),
},
PassiveHealthCheck: &capi.PassiveHealthCheck{
Interval: 2 * time.Second,
MaxFailures: uint32(10),
Interval: 2 * time.Second,
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ spec:
upstream proxy instances will be monitored for removal from
the load balancing pool.
properties:
enforcing_consecutive_5xx:
description: EnforcingConsecutive5xx is the % chance that
a host will be actually ejected when an outlier status
is detected through consecutive 5xx. This setting can
be used to disable ejection or to ramp it up slowly.
format: int32
type: integer
interval:
description: Interval between health check analysis sweeps.
Each sweep may remove hosts or return hosts to the pool.
Expand Down Expand Up @@ -326,6 +333,13 @@ spec:
how upstream proxy instances will be monitored for removal
from the load balancing pool.
properties:
enforcing_consecutive_5xx:
description: EnforcingConsecutive5xx is the % chance
that a host will be actually ejected when an outlier
status is detected through consecutive 5xx. This setting
can be used to disable ejection or to ramp it up slowly.
format: int32
type: integer
interval:
description: Interval between health check analysis
sweeps. Each sweep may remove hosts or return hosts
Expand Down
19 changes: 8 additions & 11 deletions control-plane/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ require (
github.com/go-logr/logr v0.4.0
github.com/google/go-cmp v0.5.7
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/hashicorp/consul/api v1.10.1-0.20220822180451-60c82757ea35
github.com/hashicorp/consul-k8s/control-plane/cni v0.0.0-20220831174802-b8af65262de8
github.com/hashicorp/consul/api v1.10.1-0.20220913205944-e743eefbd104
github.com/hashicorp/consul/sdk v0.11.0
github.com/hashicorp/go-discover v0.0.0-20200812215701-c4b85f6ed31f
github.com/hashicorp/go-hclog v0.16.1
github.com/hashicorp/go-hclog v1.2.2
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/serf v0.9.7
github.com/kr/text v0.2.0
github.com/miekg/dns v1.1.41
github.com/mitchellh/cli v1.1.0
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.4.1
github.com/stretchr/testify v1.7.1
github.com/stretchr/testify v1.7.2
go.uber.org/zap v1.19.0
golang.org/x/text v0.3.7
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8
Expand Down Expand Up @@ -51,13 +52,12 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/containernetworking/plugins v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661 // indirect
github.com/digitalocean/godo v1.10.0 // indirect
github.com/dimchansky/utfbom v1.1.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/go-logr/zapr v0.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand All @@ -69,7 +69,6 @@ require (
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/gophercloud/gophercloud v0.1.0 // indirect
github.com/hashicorp/consul-k8s/control-plane/cni v0.0.0-20220831174802-b8af65262de8 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-immutable-radix v1.3.0 // indirect
Expand Down Expand Up @@ -117,19 +116,17 @@ require (
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
google.golang.org/grpc v1.38.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/grpc v1.48.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/resty.v1 v1.12.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.22.2 // indirect
k8s.io/component-base v0.22.2 // indirect
k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

replace github.com/hashicorp/consul/sdk v0.10.0 => github.com/hashicorp/consul/sdk v0.4.1-0.20220801192236-988e1fd35d51

go 1.18
Loading

0 comments on commit d0297de

Please sign in to comment.