You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by li...@apache.org on 2023/03/31 03:42:25 UTC
[apisix-ingress-controller] branch v1.6.0 updated: fix: panic at empty http spec (#1660) (#1757)
This is an automated email from the ASF dual-hosted git repository.
lingsamuel pushed a commit to branch v1.6.0
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git
The following commit(s) were added to refs/heads/v1.6.0 by this push:
new df043244 fix: panic at empty http spec (#1660) (#1757)
df043244 is described below
commit df043244cbb937c505d4d9eb38a9f7c74031bd02
Author: Sarasa Kisaragi <li...@gmail.com>
AuthorDate: Fri Mar 31 11:42:20 2023 +0800
fix: panic at empty http spec (#1660) (#1757)
Co-authored-by: Basuotian <93...@users.noreply.github.com>
---
pkg/providers/ingress/translation/translator.go | 3 ++
.../suite-ingress-resource/ingress.go | 33 ++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/pkg/providers/ingress/translation/translator.go b/pkg/providers/ingress/translation/translator.go
index a4307860..ea8f31e6 100644
--- a/pkg/providers/ingress/translation/translator.go
+++ b/pkg/providers/ingress/translation/translator.go
@@ -160,6 +160,9 @@ func (t *translator) translateIngressV1(ing *networkingv1.Ingress, skipVerify bo
ns = ingress.ServiceNamespace
}
for _, rule := range ing.Spec.Rules {
+ if rule.HTTP == nil {
+ continue
+ }
for _, pathRule := range rule.HTTP.Paths {
var (
ups *apisixv1.Upstream
diff --git a/test/e2e/suite-ingress/suite-ingress-resource/ingress.go b/test/e2e/suite-ingress/suite-ingress-resource/ingress.go
index 3f32f682..923117f4 100644
--- a/test/e2e/suite-ingress/suite-ingress-resource/ingress.go
+++ b/test/e2e/suite-ingress/suite-ingress-resource/ingress.go
@@ -466,6 +466,39 @@ spec:
// Mismatched host
_ = s.NewAPISIXClient().GET("/anything/aaa/ok").WithHeader("Host", "a.httpbin.org").Expect().Status(http.StatusNotFound)
})
+
+ ginkgo.It("v1 ingress with empty http spec", func() {
+ backendSvc, backendPort := s.DefaultHTTPBackend()
+ ing := fmt.Sprintf(`
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+ annotations:
+ kubernetes.io/ingress.class: apisix
+ name: ingress-v1
+spec:
+ rules:
+ - host: empty.httpbin.org
+ - host: httpbin.org
+ http:
+ paths:
+ - path: /status
+ pathType: Prefix
+ backend:
+ service:
+ name: %s
+ port:
+ number: %d
+`, backendSvc, backendPort[0])
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(ing), "creating ingress")
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(1))
+
+ _ = s.NewAPISIXClient().GET("/status/500").WithHeader("Host", "httpbin.org").Expect().Status(http.StatusInternalServerError)
+ _ = s.NewAPISIXClient().GET("/status/504").WithHeader("Host", "httpbin.org").Expect().Status(http.StatusGatewayTimeout)
+ _ = s.NewAPISIXClient().GET("/statusaaa").WithHeader("Host", "httpbin.org").Expect().Status(http.StatusNotFound).Body().Contains("404 Route Not Found")
+ // Mismatched host
+ _ = s.NewAPISIXClient().GET("/status/200").WithHeader("Host", "empty.httpbin.org").Expect().Status(http.StatusNotFound)
+ })
})
var _ = ginkgo.Describe("suite-ingress-resource: support ingress.networking/v1beta1", func() {