Skip to content

Commit

Permalink
fix: the fields in UpstreamPassiveHealthCheckUnhealthy should be time…
Browse files Browse the repository at this point in the history
…outs (#687)
  • Loading branch information
gxthrj authored Sep 23, 2021
1 parent 5c9cdbe commit 3e9bdbf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions pkg/apisix/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package apisix

import (
"context"

"go.uber.org/zap"

"github.com/apache/apisix-ingress-controller/pkg/apisix/cache"
Expand Down
8 changes: 4 additions & 4 deletions pkg/kube/apisix/apis/config/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ type PassiveHealthCheckHealthy struct {
// PassiveHealthCheckUnhealthy defines the conditions to judge whether
// an upstream node is unhealthy with the passive manager.
type PassiveHealthCheckUnhealthy struct {
HTTPCodes []int `json:"httpCodes,omitempty" yaml:"httpCodes,omitempty"`
HTTPFailures int `json:"httpFailures,omitempty" yaml:"http_failures,omitempty"`
TCPFailures int `json:"tcpFailures,omitempty" yaml:"tcpFailures,omitempty"`
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
HTTPCodes []int `json:"httpCodes,omitempty" yaml:"httpCodes,omitempty"`
HTTPFailures int `json:"httpFailures,omitempty" yaml:"http_failures,omitempty"`
TCPFailures int `json:"tcpFailures,omitempty" yaml:"tcpFailures,omitempty"`
Timeouts int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
4 changes: 2 additions & 2 deletions pkg/kube/translation/apisix_upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (t *translator) translateUpstreamActiveHealthCheck(config *configv1.ActiveH
}
}
active.Unhealthy.TCPFailures = config.Unhealthy.TCPFailures
active.Unhealthy.Timeouts = config.Unhealthy.Timeout.Seconds()
active.Unhealthy.Timeouts = config.Unhealthy.Timeouts

if config.Unhealthy.HTTPCodes != nil && len(config.Unhealthy.HTTPCodes) < 1 {
return nil, &translateError{
Expand Down Expand Up @@ -295,7 +295,7 @@ func (t *translator) translateUpstreamPassiveHealthCheck(config *configv1.Passiv
}
}
passive.Unhealthy.TCPFailures = config.Unhealthy.TCPFailures
passive.Unhealthy.Timeouts = config.Unhealthy.Timeout.Seconds()
passive.Unhealthy.Timeouts = config.Unhealthy.Timeouts

if config.Unhealthy.HTTPCodes != nil && len(config.Unhealthy.HTTPCodes) < 1 {
return nil, &translateError{
Expand Down
8 changes: 4 additions & 4 deletions pkg/types/apisix/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ type UpstreamActiveHealthCheckUnhealthy struct {
// an upstream node is unhealthy with the passive manager.
// +k8s:deepcopy-gen=true
type UpstreamPassiveHealthCheckUnhealthy struct {
HTTPStatuses []int `json:"http_statuses,omitempty" yaml:"http_statuses,omitempty"`
HTTPFailures int `json:"http_failures,omitempty" yaml:"http_failures,omitempty"`
TCPFailures int `json:"tcp_failures,omitempty" yaml:"tcp_failures,omitempty"`
Timeouts float64 `json:"timeouts,omitempty" yaml:"timeouts,omitempty"`
HTTPStatuses []int `json:"http_statuses,omitempty" yaml:"http_statuses,omitempty"`
HTTPFailures int `json:"http_failures,omitempty" yaml:"http_failures,omitempty"`
TCPFailures int `json:"tcp_failures,omitempty" yaml:"tcp_failures,omitempty"`
Timeouts int `json:"timeouts,omitempty" yaml:"timeouts,omitempty"`
}

// Ssl apisix ssl object
Expand Down
10 changes: 6 additions & 4 deletions samples/deploy/crd/v1beta1/ApisixUpstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ spec:
type: integer
minimum: 1
maximum: 254
timeout:
type: string
timeouts:
type: integer
minimum: 0
passive:
type: object
properties:
Expand Down Expand Up @@ -211,8 +212,9 @@ spec:
type: integer
minimum: 1
maximum: 254
timeout:
type: string
timeouts:
type: integer
minimum: 0
portLevelSettings:
type: array
items:
Expand Down

0 comments on commit 3e9bdbf

Please sign in to comment.