Skip to content

Commit

Permalink
fix json tags for fields 1.0.x (#2159)
Browse files Browse the repository at this point in the history
* Fix json tags for added fields

* update tests

* update consul image

---------

Co-authored-by: Maliz <maliheh.monshizadeh@hashicorp.com>
  • Loading branch information
thisisnotashwin and Maliz authored May 26, 2023
1 parent 74ab182 commit cd8d675
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .changelog/2159.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
control-plane: fix issue with json tags of service defaults fields EnforcingConsecutive5xx, MaxEjectionPercent and BaseEjectionTime.
```
32 changes: 24 additions & 8 deletions charts/consul/templates/crd-servicedefaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,14 @@ spec:
upstream proxy instances will be monitored for removal from
the load balancing pool.
properties:
enforcing_consecutive_5xx:
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
enforcingConsecutive5xx:
description: EnforcingConsecutive5xx is the % chance that
a host will be actually ejected when an outlier status
is detected through consecutive 5xx. This setting can
Expand All @@ -263,6 +270,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 @@ -352,12 +366,13 @@ spec:
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 30s.
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:
enforcingConsecutive5xx:
description: EnforcingConsecutive5xx is the % chance
that a host will be actually ejected when an outlier
status is detected through consecutive 5xx. This setting
Expand All @@ -371,8 +386,9 @@ spec:
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.
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:
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ global:
# image: "hashicorp/consul-enterprise:1.10.0-ent"
# ```
# @default: hashicorp/consul:<latest version>
image: "hashicorp/consul:1.14.7"
image: "docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.14-dev"

# Array of objects containing image pull secret names that will be applied to each service account.
# This can be used to reference image pull secrets if using a custom consul or consul-k8s-control-plane Docker image.
Expand Down
9 changes: 4 additions & 5 deletions control-plane/api/v1alpha1/servicedefaults_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"net"
"strings"
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
Expand Down Expand Up @@ -172,14 +171,14 @@ type PassiveHealthCheck struct {
// 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"`
EnforcingConsecutive5xx *uint32 `json:"enforcingConsecutive5xx,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:",omitempty" alias:"max_ejection_percent"`
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 *time.Duration `json:",omitempty" alias:"base_ejection_time"`
BaseEjectionTime *metav1.Duration `json:"baseEjectionTime,omitempty"`
}

type ServiceDefaultsDestination struct {
Expand Down Expand Up @@ -422,7 +421,7 @@ func (in *PassiveHealthCheck) toConsul() *capi.PassiveHealthCheck {
MaxFailures: in.MaxFailures,
EnforcingConsecutive5xx: in.EnforcingConsecutive5xx,
MaxEjectionPercent: in.MaxEjectionPercent,
BaseEjectionTime: in.BaseEjectionTime,
BaseEjectionTime: &in.BaseEjectionTime.Duration,
}
}

Expand Down
24 changes: 18 additions & 6 deletions control-plane/api/v1alpha1/servicedefaults_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: pointer.Duration(10 * time.Second),
BaseEjectionTime: &metav1.Duration{
Duration: 10 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "local",
Expand All @@ -113,7 +115,9 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(20),
BaseEjectionTime: pointer.Duration(20 * time.Second),
BaseEjectionTime: &metav1.Duration{
Duration: 20 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand All @@ -139,7 +143,9 @@ func TestServiceDefaults_ToConsul(t *testing.T) {
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(30),
BaseEjectionTime: pointer.Duration(30 * time.Second),
BaseEjectionTime: &metav1.Duration{
Duration: 30 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand Down Expand Up @@ -361,7 +367,9 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: pointer.Duration(10 * time.Second),
BaseEjectionTime: &metav1.Duration{
Duration: 10 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "local",
Expand All @@ -387,7 +395,9 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(20),
BaseEjectionTime: pointer.Duration(20 * time.Second),
BaseEjectionTime: &metav1.Duration{
Duration: 20 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand All @@ -412,7 +422,9 @@ func TestServiceDefaults_MatchesConsul(t *testing.T) {
MaxFailures: uint32(10),
EnforcingConsecutive5xx: pointer.Uint32(60),
MaxEjectionPercent: pointer.Uint32(30),
BaseEjectionTime: pointer.Duration(30 * time.Second),
BaseEjectionTime: &metav1.Duration{
Duration: 30 * time.Second,
},
},
MeshGateway: MeshGateway{
Mode: "remote",
Expand Down
4 changes: 2 additions & 2 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 @@ -246,12 +246,13 @@ spec:
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 30s.
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:
enforcingConsecutive5xx:
description: EnforcingConsecutive5xx is the % chance that
a host will be actually ejected when an outlier status
is detected through consecutive 5xx. This setting can
Expand All @@ -265,7 +266,8 @@ spec:
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.
10% but will eject at least one host regardless of the
value.
format: int32
type: integer
maxFailures:
Expand Down Expand Up @@ -357,12 +359,13 @@ spec:
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 30s.
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:
enforcingConsecutive5xx:
description: EnforcingConsecutive5xx is the % chance
that a host will be actually ejected when an outlier
status is detected through consecutive 5xx. This setting
Expand All @@ -376,8 +379,9 @@ spec:
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.
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:
Expand Down

0 comments on commit cd8d675

Please sign in to comment.