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

update service config crds, update passive health check #1484

Merged
merged 7 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 17 additions & 4 deletions control-plane/api/v1alpha1/servicedefaults_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package v1alpha1

import (
"fmt"
"net"
"strings"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/hashicorp/consul-k8s/control-plane/api/common"
Expand All @@ -12,8 +15,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation/field"
"net"
"strings"
)

const (
Expand Down Expand Up @@ -160,6 +161,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 +391,17 @@ func (in *PassiveHealthCheck) toConsul() *capi.PassiveHealthCheck {
if in == nil {
return nil
}

var enforcingConsecutive5xx uint32
if in.EnforcingConsecutive5xx == nil {
enforcingConsecutive5xx = 100
} else {
enforcingConsecutive5xx = *in.EnforcingConsecutive5xx
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is allowed to be nil so that it will use the envoy default. I think it's safe to pass through directly in the return below.

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

Expand Down
52 changes: 34 additions & 18 deletions control-plane/api/v1alpha1/servicedefaults_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(20),
MaxFailures: uint32(20),
EnforcingConsecutive5xx: uint32Pointer(100),
},
MeshGateway: MeshGateway{
Mode: "local",
Expand All @@ -106,7 +107,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(10),
MaxFailures: uint32(10),
EnforcingConsecutive5xx: uint32Pointer(60),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand All @@ -129,7 +131,8 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(10),
MaxFailures: uint32(10),
EnforcingConsecutive5xx: uint32Pointer(60),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand Down Expand Up @@ -188,8 +191,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: uint32(100),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "local",
Expand All @@ -210,8 +214,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: *uint32Pointer(60),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand All @@ -231,8 +236,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: uint32(60),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand Down Expand Up @@ -335,7 +341,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(20),
MaxFailures: uint32(20),
EnforcingConsecutive5xx: uint32Pointer(100),
},
MeshGateway: MeshGateway{
Mode: "local",
Expand All @@ -358,7 +365,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(10),
MaxFailures: uint32(10),
EnforcingConsecutive5xx: uint32Pointer(60),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand All @@ -380,7 +388,8 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(10),
MaxFailures: uint32(10),
EnforcingConsecutive5xx: uint32Pointer(60),
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand Down Expand Up @@ -436,8 +445,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: *uint32Pointer(100),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "local",
Expand All @@ -457,8 +467,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: *uint32Pointer(60),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand All @@ -477,8 +488,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: uint32(60),
},
MeshGateway: capi.MeshGatewayConfig{
Mode: "remote",
Expand Down Expand Up @@ -1027,3 +1039,7 @@ func TestServiceDefaults_ObjectMeta(t *testing.T) {
func intPointer(i int) *int {
return &i
}

func uint32Pointer(i uint32) *uint32 {
return &i
}
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
2 changes: 1 addition & 1 deletion control-plane/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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/api v1.10.1-0.20220906101351-9675faeab570
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
Expand Down
2 changes: 2 additions & 0 deletions control-plane/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ github.com/hashicorp/consul-k8s/control-plane/cni v0.0.0-20220831174802-b8af6526
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
github.com/hashicorp/consul/api v1.10.1-0.20220822180451-60c82757ea35 h1:csNww5qBHaFqsX1eMEKVvmJ4dhqcXWj0sCkbccsSsHc=
github.com/hashicorp/consul/api v1.10.1-0.20220822180451-60c82757ea35/go.mod h1:bcaw5CSZ7NE9qfOfKCI1xb7ZKjzu/MyvQkCLTfqLqxQ=
github.com/hashicorp/consul/api v1.10.1-0.20220906101351-9675faeab570 h1:ckegGAL9YceZ24TcQmcrqeUPwb2u/mRm5/XAZZhE9XE=
github.com/hashicorp/consul/api v1.10.1-0.20220906101351-9675faeab570/go.mod h1:bcaw5CSZ7NE9qfOfKCI1xb7ZKjzu/MyvQkCLTfqLqxQ=
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/consul/sdk v0.4.1-0.20220801192236-988e1fd35d51/go.mod h1:yPkX5Q6CsxTFMjQQDJwzeNmUUF5NUGGbrDsv9wTb8cw=
github.com/hashicorp/consul/sdk v0.11.0 h1:HRzj8YSCln2yGgCumN5CL8lYlD3gBurnervJRJAZyC4=
Expand Down