Skip to content

Commit

Permalink
fix timeout type in webservice crds
Browse files Browse the repository at this point in the history
  • Loading branch information
Cypherspark committed Sep 18, 2023
1 parent 1939863 commit cea8671
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions api/v1alpha1/webservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package v1alpha1

import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -59,9 +58,9 @@ type UpstreamHttpAuthService struct {
// +optional
CareHeaders []string `json:"careHeaders,omitempty"`

// +kubebuilder:default="200ms"
// Timeout specifies the duration to wait before timing out the request to the upstream authentication service.
Timeout time.Duration `json:"timeout"`
// +kubebuilder:default=200
// Timeout specifies the milliseconds duration to wait before timing out the request to the upstream authentication service.
Timeout int `json:"timeout"`
}

// WebServiceStatus defines the observed state of WebService
Expand Down
8 changes: 4 additions & 4 deletions config/crd/bases/cerberus.snappcloud.io_webservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ spec:
upstream Auth token in the request
type: string
timeout:
default: 200ms
description: Timeout specifies the duration to wait before timing
out the request to the upstream authentication service.
format: int64
default: 200
description: Timeout specifies the milliseconds duration to wait
before timing out the request to the upstream authentication
service.
type: integer
writeTokenTo:
default: Authorization
Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (a *Authenticator) checkServiceUpstreamAuth(service ServicesCacheEntry, req
"Content-Type": {"application/json"},
}

a.httpClient.Timeout = service.Spec.UpstreamHttpAuth.Timeout
a.httpClient.Timeout = time.Duration(service.Spec.UpstreamHttpAuth.Timeout) * time.Millisecond
reqStart := time.Now()
resp, err := a.httpClient.Do(req)
reqDuration := time.Since(reqStart)
Expand Down

0 comments on commit cea8671

Please sign in to comment.