tao12345666333 commented on code in PR #1674:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/1674#discussion_r1124052774


##########
conf/config-default.yaml:
##########
@@ -64,7 +64,8 @@ kubernetes:
   election_id: "ingress-apisix-leader" # the election id for the controller 
leader campaign,
                                        # only the leader will watch and 
delivery resource changes,
                                        # other instances (as candidates) stand 
by.
-  ingress_class: "apisix"              # the class of an Ingress object is set 
using the field
+  ingress_class: "apisix-and-all"      # apisix-and-all is a special value, it 
handles Ingress resources with ingressClassName=apisix and all CRDs.
+                                       # the class of an Ingress object is set 
using the field

Review Comment:
   this field can be used for both Ingress Object and custom resources.



##########
test/e2e/suite-ingress/suite-ingress-features/ingress-class.go:
##########
@@ -0,0 +1,204 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package ingress
+
+import (
+       "fmt"
+       "net/http"
+       "time"
+
+       ginkgo "github.com/onsi/ginkgo/v2"
+       "github.com/stretchr/testify/assert"
+
+       "github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
+)
+
+var _ = ginkgo.Describe("suite-ingress-features: Testing CRDs with 
IngressClass", func() {
+       s := scaffold.NewScaffold(&scaffold.Options{
+               Name:                  "ingress-class",
+               IngressAPISIXReplicas: 1,
+               IngressClass:          "apisix",
+       })
+       ginkgo.It("ApisiUpstream should be ignored", func() {
+               backendSvc, backendSvcPort := s.DefaultHTTPBackend()
+               au := fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2
+kind: ApisixUpstream
+metadata:
+  name: %s
+spec:
+  ingressClassName: ignore
+  retries: 3
+`, backendSvc)
+               assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(au))
+               time.Sleep(6 * time.Second)
+
+               apisixRoute := fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2
+kind: ApisixRoute
+metadata:
+  name: httpbin-route
+spec:
+  http:
+  - name: rule1
+    match:
+      hosts:
+      - httpbin.org
+      paths:
+      - /ip
+    backends:
+    - serviceName: %s
+      servicePort: %d
+`, backendSvc, backendSvcPort[0])
+               assert.Nil(ginkgo.GinkgoT(), 
s.CreateResourceFromString(apisixRoute))
+               time.Sleep(6 * time.Second)
+
+               ups, err := s.ListApisixUpstreams()
+               assert.Nil(ginkgo.GinkgoT(), err)
+               assert.Len(ginkgo.GinkgoT(), ups, 1)
+               assert.Nil(ginkgo.GinkgoT(), ups[0].Retries)
+
+               err = s.EnsureNumApisixRoutesCreated(1)
+               assert.Nil(ginkgo.GinkgoT(), err, "Checking number of routes")
+               err = s.EnsureNumApisixUpstreamsCreated(1)
+               assert.Nil(ginkgo.GinkgoT(), err, "Checking number of 
upstreams")
+
+               s.NewAPISIXClient().GET("/ip").WithHeader("Host", 
"httpbin.org").Expect().Status(http.StatusOK)

Review Comment:
   This is not as expected.
   
   ApisixUpstream will be ignored.



##########
pkg/providers/utils/ingress_class.go:
##########
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package utils
+
+import "github.com/apache/apisix-ingress-controller/pkg/config"
+
+func MatchCRDsIngressClass(resourceIngressClassName string, configIngressClass 
string) bool {

Review Comment:
   Will the resourceIngressClassName field be empty (nil)?  This field does not 
exist for legacy resources.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to