Skip to content

Commit

Permalink
fix for v1 and v1beta1
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Tiwari <[email protected]>
  • Loading branch information
Revolyssup committed Dec 7, 2023
1 parent 8ef9dc3 commit 6fd0730
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
39 changes: 29 additions & 10 deletions pkg/providers/ingress/translation/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,21 @@ func (t *translator) translateIngressV1(ing *networkingv1.Ingress, skipVerify bo
ups.Retries = &retry
fmt.Println("set retries", *ups.Retries)
}
if ingress.Upstream.TimeoutConnect > 0 {
if ups.Timeout == nil {
ups.Timeout = &apisixv1.UpstreamTimeout{}
if ups.Timeout == nil {
ups.Timeout = &apisixv1.UpstreamTimeout{
Read: 60,
Send: 60,
Connect: 60,
}
}
if ingress.Upstream.TimeoutConnect > 0 {
ups.Timeout.Connect = ingress.Upstream.TimeoutConnect
}
if ingress.Upstream.TimeoutRead > 0 {
if ups.Timeout == nil {
ups.Timeout = &apisixv1.UpstreamTimeout{}
}
ups.Timeout.Read = ingress.Upstream.TimeoutRead
fmt.Println("set read rimeiut", ups.Timeout.Read)
}
if ingress.Upstream.TimeoutSend > 0 {
if ups.Timeout == nil {
ups.Timeout = &apisixv1.UpstreamTimeout{}
}
ups.Timeout.Send = ingress.Upstream.TimeoutSend
}
ctx.AddUpstream(ups)
Expand Down Expand Up @@ -383,7 +381,28 @@ func (t *translator) translateIngressV1beta1(ing *networkingv1beta1.Ingress, ski
if len(ingress.Plugins) > 0 {
route.Plugins = *(ingress.Plugins.DeepCopy())
}

if ingress.Upstream.Retry > 0 {
retry := ingress.Upstream.Retry
ups.Retries = &retry
fmt.Println("set retries", *ups.Retries)
}
if ups.Timeout == nil {
ups.Timeout = &apisixv1.UpstreamTimeout{
Read: 60,
Send: 60,
Connect: 60,
}
}
if ingress.Upstream.TimeoutConnect > 0 {
ups.Timeout.Connect = ingress.Upstream.TimeoutConnect
}
if ingress.Upstream.TimeoutRead > 0 {
ups.Timeout.Read = ingress.Upstream.TimeoutRead
fmt.Println("set read rimeiut", ups.Timeout.Read)
}
if ingress.Upstream.TimeoutSend > 0 {
ups.Timeout.Send = ingress.Upstream.TimeoutSend
}
if ingress.PluginConfigName != "" {
route.PluginConfigId = id.GenID(apisixv1.ComposePluginConfigName(ing.Namespace, ingress.PluginConfigName))
}
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/scaffold/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,6 @@ spec:
- --etcd-server-enabled=%t
- --etcd-server-listen-address
- ":2379"
- "--ingress-publish-service"
- "default/apisix-service-e2e-test"
volumeMounts:
- name: admission-webhook
mountPath: /etc/webhook/certs
Expand Down
9 changes: 3 additions & 6 deletions test/e2e/suite-annotations/upstreamretry.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,9 @@ spec:
port:
number: 9280
`
assert.NoError(ginkgo.GinkgoT(), s.CreateResourceFromString(ing))
err := s.EnsureNumApisixUpstreamsCreated(1)
if err != nil {
fmt.Println("should not err", err.Error())
}
time.Sleep(2 * time.Second)
err := s.CreateResourceFromString(ing)
assert.Nil(ginkgo.GinkgoT(), err, "creating ingress")
time.Sleep(5 * time.Second)

respGet := s.NewAPISIXClient().GET("/retry").WithHeader("Host", "e2e.apisix.local").Expect()
respGet.Status(http.StatusGatewayTimeout)
Expand Down

0 comments on commit 6fd0730

Please sign in to comment.