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

Manual backport 5xx #1562

Merged
merged 1 commit into from
Sep 29, 2022
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
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