Skip to content

Commit

Permalink
update service config crds, update passive health check
Browse files Browse the repository at this point in the history
  • Loading branch information
Maliz committed Sep 6, 2022
1 parent beff736 commit 65322a1
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 23 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
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
}
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

0 comments on commit 65322a1

Please sign in to comment.