This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e9bdbf  fix: the fields in UpstreamPassiveHealthCheckUnhealthy should 
be timeouts (#687)
3e9bdbf is described below

commit 3e9bdbf0cee6d49c8e0db27152d46565df704e8c
Author: kv <[email protected]>
AuthorDate: Thu Sep 23 10:47:39 2021 +0800

    fix: the fields in UpstreamPassiveHealthCheckUnhealthy should be timeouts 
(#687)
---
 pkg/apisix/schema.go                           |  1 +
 pkg/kube/apisix/apis/config/v1/types.go        |  8 ++++----
 pkg/kube/translation/apisix_upstream.go        |  4 ++--
 pkg/types/apisix/v1/types.go                   |  8 ++++----
 samples/deploy/crd/v1beta1/ApisixUpstream.yaml | 10 ++++++----
 5 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/pkg/apisix/schema.go b/pkg/apisix/schema.go
index 3f30525..34ce2ce 100644
--- a/pkg/apisix/schema.go
+++ b/pkg/apisix/schema.go
@@ -17,6 +17,7 @@ package apisix
 
 import (
        "context"
+
        "go.uber.org/zap"
 
        "github.com/apache/apisix-ingress-controller/pkg/apisix/cache"
diff --git a/pkg/kube/apisix/apis/config/v1/types.go 
b/pkg/kube/apisix/apis/config/v1/types.go
index 3eea11a..61d9f3f 100644
--- a/pkg/kube/apisix/apis/config/v1/types.go
+++ b/pkg/kube/apisix/apis/config/v1/types.go
@@ -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
diff --git a/pkg/kube/translation/apisix_upstream.go 
b/pkg/kube/translation/apisix_upstream.go
index f9ce843..40fd598 100644
--- a/pkg/kube/translation/apisix_upstream.go
+++ b/pkg/kube/translation/apisix_upstream.go
@@ -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{
@@ -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{
diff --git a/pkg/types/apisix/v1/types.go b/pkg/types/apisix/v1/types.go
index 297f915..5838028 100644
--- a/pkg/types/apisix/v1/types.go
+++ b/pkg/types/apisix/v1/types.go
@@ -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
diff --git a/samples/deploy/crd/v1beta1/ApisixUpstream.yaml 
b/samples/deploy/crd/v1beta1/ApisixUpstream.yaml
index aebb4e1..3bf9349 100644
--- a/samples/deploy/crd/v1beta1/ApisixUpstream.yaml
+++ b/samples/deploy/crd/v1beta1/ApisixUpstream.yaml
@@ -168,8 +168,9 @@ spec:
                           type: integer
                           minimum: 1
                           maximum: 254
-                        timeout:
-                          type: string
+                        timeouts:
+                          type: integer
+                          minimum: 0
                 passive:
                   type: object
                   properties:
@@ -211,8 +212,9 @@ spec:
                           type: integer
                           minimum: 1
                           maximum: 254
-                        timeout:
-                          type: string
+                        timeouts:
+                          type: integer
+                          minimum: 0
             portLevelSettings:
               type: array
               items:

Reply via email to